refine
refine<S extends Schema<any, unknown>>(
name: string,
refine: Object,
meta?: unknown,
): Object
Type Parameters
- S extends Schema<any, unknown>
Parameters
name: string
refine: Object
Optional
meta: unknown
Returns Object
refine<T, S extends Schema<T, unknown>>(
name: string,
refine: Object,
meta?: unknown,
): Object
Type Parameters
Parameters
name: string
refine: Object
Optional
meta: unknown
Returns Object
Example
import * as x from 'unhoax'
declare const isEmail: (input: string) => boolean
const refineAsEmail = x.refine('Email', isEmail)
const emailSchema = refineAsEmail(x.string) // Schema<string>
// or, using pipe:
import pipe from 'just-pipe'
const emailSchema: Schema<string> = pipe(
x.string,
x.refine('Email', isEmail),
)
Example