Module

std/uuid/mod.ts>v4.validate

Deno standard library
Go to Latest
function v4.validate
import { v4 } from "https://dotland.deno.dev/std@0.116.0/uuid/mod.ts";
const { validate } = v4;

Validate that the passed UUID is an RFC4122 v4 UUID.

import { validate } from "./v4.ts";
import { generate as generateV1 } from "./v1.ts";

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

Parameters

id: string

Returns

boolean