mirror of
https://github.com/bknd-io/bknd.git
synced 2026-10-23 14:55:11 +00:00
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.
This commit is contained in:
1 parent
210b22e307
commit
e6ef7d9ff4
1 file changed
+9
-3
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user