Refactored isuuid to own utils

This commit is contained in:
GeorgeWebberley 2026-03-01 12:21:12 +01:00
parent cf4a2f16bd
commit 36f34257d2
2 changed files with 7 additions and 6 deletions

View file

@ -1,5 +1,6 @@
import { Injectable, NotFoundException, BadRequestException, Logger, Inject } from '@nestjs/common'; import { Injectable, NotFoundException, BadRequestException, Logger, Inject } from '@nestjs/common';
import { PRISMA_CLIENT, type PrismaClientInstance } from '../common/prisma/prisma.service'; import { PRISMA_CLIENT, type PrismaClientInstance } from '../common/prisma/prisma.service';
import { isUuid } from 'src/common/utils/string.utils';
@Injectable() @Injectable()
export class CasesService { export class CasesService {
@ -40,8 +41,3 @@ export class CasesService {
return caseLaw; 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);
};

View 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);
};