fromPredicate<T, Input = unknown>( name: string, predicate: Predicate<Input, T>,): Schema<T, Input>
Utility to create schemas. Can be used to create custom schemas like Email.
Email
name: string
predicate: Predicate<Input, T>
import * as x from 'unhoax'const string = x.fromPredicate( 'string', (input) => typeof input === 'string')// creating an email type:type Email = string & { _tag: 'Email' }declare const isEmail: (input: unknown) => input is Emailconst email = x.fromPredicate('Email', isEmail) Copy
import * as x from 'unhoax'const string = x.fromPredicate( 'string', (input) => typeof input === 'string')// creating an email type:type Email = string & { _tag: 'Email' }declare const isEmail: (input: unknown) => input is Emailconst email = x.fromPredicate('Email', isEmail)
Utility to create schemas.
Can be used to create custom schemas like
Email
.