Skip to main content
Module

std/uuid/mod.ts>v4.validate

The Deno Standard Library
Latest
function v4.validate
import { v4 } from "https://deno.land/std@0.222.1/uuid/mod.ts";
const { validate } = v4;

Validate that the passed UUID is an RFC4122 v4 UUID.

Examples

Example 1

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

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

Parameters

id: string

Returns

id is ReturnType<crypto.randomUUID>