Given a Schema, returns a Type Guard that checks that the given value is a object exactly implementing the entries of the Schema.
This Type Guard returns false if a given value contains keys that are not specified in the Schema. If you want to allow unknown keys, see matchSchema
matchSchema
import { matchExactSchema, match } from 'type-guard-helpers'const test = {} as unknownconst isFoo = match'foo');const isBar = match'bar');const isFooObject = matchExactSchema({ foo: isFoo, bar: isBar})if(isFooObject(test)){ test; // { readonly foo: "foo"; readonly bar: "bar"; }}
Generated using TypeDoc
Given a Schema, returns a Type Guard that checks that the given value is a object exactly implementing the entries of the Schema.
This Type Guard returns false if a given value contains keys that are not specified in the Schema. If you want to allow unknown keys, see
matchSchema
Example