Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/uuid/v4.ts>validate

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function validate
import { validate } from "https://deno.land/std@0.190.0/uuid/v4.ts";

Validate that the passed UUID is an RFC4122 v4 UUID.

Examples

Example 1

import { validate } from "https://deno.land/std@0.190.0/uuid/v4.ts";
import { generate as generateV1 } from "https://deno.land/std@0.190.0/uuid/v1.ts";

validate(crypto.randomUUID()); // true
validate(generateV1() as string); // false
validate("this-is-not-a-uuid"); // false

Parameters

id: string

Returns

boolean