tests
This commit is contained in:
@@ -15,6 +15,12 @@ export class TypeOrmTeamRepository implements ITeamRepository {
|
||||
) {}
|
||||
|
||||
async findById(id: string): Promise<Team | null> {
|
||||
// Validate UUID format to prevent database errors
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
if (!uuidRegex.test(id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const entity = await this.repo.findOne({ where: { id } });
|
||||
return entity ? this.mapper.toDomain(entity) : null;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,12 @@ export class TypeOrmDriverRepository implements IDriverRepository {
|
||||
) {}
|
||||
|
||||
async findById(id: string): Promise<Driver | null> {
|
||||
// Validate UUID format to prevent database errors
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
if (!uuidRegex.test(id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const repo = this.dataSource.getRepository(DriverOrmEntity);
|
||||
const entity = await repo.findOne({ where: { id } });
|
||||
return entity ? this.mapper.toDomain(entity) : null;
|
||||
|
||||
Reference in New Issue
Block a user