validate

import { validate } from "jsr:@ende/uuid/v4";

function

function validate(id: string): id is ReturnType<typeof crypto.randomUUID>

Determines whether a string is a valid UUIDv4.

id: string

UUID value.

Returns

true if the UUID is valid UUIDv4, otherwise false.

Example: Usage

import { validate } from "@ende/uuid/v4";
import { assert, assertFalse } from "@ende/assert";

assert(validate(crypto.randomUUID()));
assertFalse(validate("this-is-not-a-uuid"));

Source