fromGuard<T, Input = unknown>( name: string, guard: Guard<Input, T>,): Schema<T, Input>
Utility to create schemas. Used to create most of the primitives. Can be used to create custom schemas like Email.
Email
name: string
guard: Guard<Input, T>
import { x } from 'unhoax'const string = x.fromGuard( 'string', (input) => typeof input === 'string')// creating an email type:type Email = string & { _tag: 'Email' }declare const isEmail: (input: unknown) => input is Emailconst email = x.fromGuard('Email', isEmail) Copy
import { x } from 'unhoax'const string = x.fromGuard( 'string', (input) => typeof input === 'string')// creating an email type:type Email = string & { _tag: 'Email' }declare const isEmail: (input: unknown) => input is Emailconst email = x.fromGuard('Email', isEmail)
Utility to create schemas.
Used to create most of the primitives.
Can be used to create custom schemas like
Email
.