Skip to content

guard

guard<T>(source, predicate, reason?): GuardSpec<T>

Defined in: extract/spec.ts:498

Validate a successfully extracted value against a predicate. Fails with ‘constraint’ kind if the predicate returns false.

T extends Spec

T

(value) => boolean

string

GuardSpec<T>

guard(
$.get('age').number(),
v => (v as number) > 0,
'Age must be positive'
)