Skip to content

validate

validate(value): value is string

Defined in: src/uuid/codec.ts:127

Whether value is a well-formed UUID string.

Checks the fields RFC 9562 constrains, not just the shape: the version nibble must be 1 through 8 (§4.1) and the variant must be 10xx (§4.2). Nil (§5.9) and Max (§5.10) are accepted as the two named exceptions.

unknown

value is string

validate(v4()); // true
validate(NIL); // true
validate(MAX); // true
validate("nope"); // false
validate(42); // false
// Right shape, but no such version and the wrong variant bits.
validate("11111111-1111-9111-1111-111111111111"); // false