- shape<input, const pattern>(pattern): Chainable<GuardP<input, InvertPattern<pattern, input>>>
Type Parameters
- input
- const pattern extends undefined | null | string | number | bigint | boolean | symbol | readonly [] | readonly [unknown, unknown] | readonly [unknown, unknown] | {
[k: string]: unknown;
} | UnknownMatcher | readonly UnknownPattern[] | readonly [UnknownPattern, UnknownPattern] | readonly [UnknownPattern, UnknownPattern] | PatternMatcher<input> | {
readonly [k in string | number | symbol]?: Pattern<Readonly<MergeUnion<Exclude<input, readonly any[] | Primitives | Map<any, any> | Set<any>>>>[k]>
}
Returns Chainable<GuardP<input, InvertPattern<pattern, input>>>
P.shape(somePattern)
lets you call methods like.optional()
,.and
,.or
and.select()
On structural patterns, like objects and arrays.Read the documentation for
P.shape
on GitHub