Refactored isuuid to own utils
This commit is contained in:
parent
cf4a2f16bd
commit
36f34257d2
|
|
@ -1,5 +1,6 @@
|
|||
import { Injectable, NotFoundException, BadRequestException, Logger, Inject } from '@nestjs/common';
|
||||
import { PRISMA_CLIENT, type PrismaClientInstance } from '../common/prisma/prisma.service';
|
||||
import { isUuid } from 'src/common/utils/string.utils';
|
||||
|
||||
@Injectable()
|
||||
export class CasesService {
|
||||
|
|
@ -39,9 +40,4 @@ export class CasesService {
|
|||
if (!caseLaw) throw new NotFoundException('Case not found');
|
||||
return caseLaw;
|
||||
}
|
||||
}
|
||||
|
||||
export const isUuid = (value: string): boolean => {
|
||||
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
||||
};
|
||||
|
||||
}
|
||||
5
src/common/utils/string.utils.ts
Normal file
5
src/common/utils/string.utils.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
// Validates if a string is a valid UUID v4 format. Would eventually move to class-validator to "fail early"
|
||||
export const isUuid = (value: string): boolean => {
|
||||
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
||||
};
|
||||
Loading…
Reference in a new issue