(
version?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8,
annotations?: Annotations.Filter
): SchemaAST.Filter<string>Validates that a string is a strict Universally Unique Identifier (UUID).
When to use
Use when you need UUID semantics, including version and RFC variant bits, rather than only the dashed hexadecimal shape.
Details
Without a version argument, this accepts UUID versions 1 through 8, the nil
UUID (00000000-0000-0000-0000-000000000000), and the max UUID
(ffffffff-ffff-ffff-ffff-ffffffffffff). With a version argument, this
accepts only UUIDs with that version and RFC variant bits; nil and max UUIDs
are not versioned UUIDs and do not match version-specific checks.
JSON Schema:
This check corresponds to a pattern constraint in JSON Schema that matches
UUID format, and includes a format: "uuid" annotation.
Arbitrary:
When generating test data with fast-check, this applies a patterns
constraint to ensure generated strings match the UUID pattern.
export function function isUUID(
version?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8,
annotations?: Annotations.Filter
): SchemaAST.Filter<string>
Validates that a string is a strict Universally Unique Identifier (UUID).
When to use
Use when you need UUID semantics, including version and RFC variant bits,
rather than only the dashed hexadecimal shape.
Details
Without a version argument, this accepts UUID versions 1 through 8, the nil
UUID (00000000-0000-0000-0000-000000000000), and the max UUID
(ffffffff-ffff-ffff-ffff-ffffffffffff). With a version argument, this
accepts only UUIDs with that version and RFC variant bits; nil and max UUIDs
are not versioned UUIDs and do not match version-specific checks.
JSON Schema:
This check corresponds to a pattern constraint in JSON Schema that matches
UUID format, and includes a format: "uuid" annotation.
Arbitrary:
When generating test data with fast-check, this applies a patterns
constraint to ensure generated strings match the UUID pattern.
isUUID(version: | 2
| 1
| 3
| 4
| 5
| 6
| 7
| 8
| undefined
version?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8, annotations: Annotations.Filter | undefinedannotations?: Annotations.interface Annotations.FilterAnnotations for filter schema nodes (created via Schema.filter). Extends
Augment
with an optional error message, identifier, and metadata.
Filters are intentionally non-parametric to keep them covariant.
Filter) {
const const regExp: globalThis.RegExpregExp = const getUUIDRegExp: (
version?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
) => globalThis.RegExp
Returns a RegExp for validating an RFC 9562 / RFC 4122 UUID.
Optionally specify a version 1-8. If no version is specified (undefined), all versions are supported.
getUUIDRegExp(version: | 2
| 1
| 3
| 4
| 5
| 6
| 7
| 8
| undefined
version)
return const isPattern: (
regExp: globalThis.RegExp,
annotations?: Annotations.Filter
) => SchemaAST.Filter<string>
Validates that a string matches the specified regular expression pattern.
Details
JSON Schema:
This check corresponds to the pattern constraint in JSON Schema.
Arbitrary:
When generating test data with fast-check, this applies a patterns
constraint to ensure generated strings match the specified RegExp pattern.
isPattern(
const regExp: globalThis.RegExpregExp,
{
Annotations.Augment.expected?: string | undefinedHuman-readable description of what a value is expected to satisfy.
Details
For filter and refinement failures, the default formatter uses
message first, then expected, and finally falls back to <filter>.
Use this to name a failed filter in the default message:
Expected <expected>, got <actual>.
expected: version: | 2
| 1
| 3
| 4
| 5
| 6
| 7
| 8
| undefined
version ? `a UUID v${version: 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8version}` : "a UUID",
Annotations.Filter.meta?: Annotations.Meta | undefined(property) Annotations.Filter.meta?: {
_tag: 'isUUID';
regExp: globalThis.RegExp;
version: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | undefined;
}
Optional metadata used to identify or extend the filter with custom data.
meta: {
_tag: "isUUID"_tag: "isUUID",
regExp: globalThis.RegExpregExp,
version: | 2
| 1
| 3
| 4
| 5
| 6
| 7
| 8
| undefined
version
},
...annotations: Annotations.Filter | undefinedannotations
}
)
}