Skip to main content Link Menu Expand (external link) Document Search Copy Copied

UUID overview

Added in v0.4.6


Table of contents


UUIDBrand (interface)

Signature

export interface UUIDBrand {
  readonly UUID: unique symbol
}

Added in v0.4.6

UUID (type alias)

Signature

export type UUID = t.Branded<string, UUIDBrand>

Added in v0.4.6

UUID

Signature

export const UUID: t.BrandC<t.StringC, UUIDBrand> = ...

Example

import { UUID } from 'io-ts-types/lib/UUID'
import { right } from 'fp-ts/lib/Either'
import { PathReporter } from 'io-ts/lib/PathReporter'

assert.deepStrictEqual(
  UUID.decode('00000000-0000-0000-0000-000000000000'),
  right('00000000-0000-0000-0000-000000000000')
)
assert.deepStrictEqual(PathReporter.report(UUID.decode('not a uuid')), [
  'Invalid value "not a uuid" supplied to : UUID'
])

Added in v0.4.6