From e6ef7d9ff44f713ded79595bc6fb79cf51e55c02 Mon Sep 17 00:00:00 2001 From: anton Date: Mon, 8 Sep 2025 04:06:24 +0200 Subject: [PATCH] Add UUID validation utility Add uuidValidate function to validate UUID strings and check their version. Supports validation for v4 and v7 UUIDs using the uuid library's validate and version functions. --- app/src/core/utils/uuid.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/core/utils/uuid.ts b/app/src/core/utils/uuid.ts index e3112e2..99511af 100644 --- a/app/src/core/utils/uuid.ts +++ b/app/src/core/utils/uuid.ts @@ -1,10 +1,16 @@ -import { v4, v7 } from "uuid"; +import { v4, v7, validate, version as uuidVersion } from "uuid"; // generates v4 export function uuid(): string { - return v4(); + return v4(); } +// generates v7 export function uuidv7(): string { - return v7(); + return v7(); +} + +// validate uuid +export function uuidValidate(uuid: string, version: 4 | 7): boolean { + return validate(uuid) && uuidVersion(uuid) === version; }