Hyperlinkv0.8.0-beta.28

Schema

Schema.isUUIDfunctioneffect/Schema.ts:6676
(
  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.

String checksisGUID
Source effect/Schema.ts:667615 lines
export function isUUID(version?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8, annotations?: Annotations.Filter) {
  const regExp = getUUIDRegExp(version)
  return isPattern(
    regExp,
    {
      expected: version ? `a UUID v${version}` : "a UUID",
      meta: {
        _tag: "isUUID",
        regExp,
        version
      },
      ...annotations
    }
  )
}
Referenced by 1 symbols