MCPcopy
hub / github.com/sindresorhus/ow / exactShape

Method exactShape

source/predicates/array.ts:162–169  ·  view source on GitHub ↗

Test if the elements in the array exactly matches the elements placed at the same indices in the predicates array. @param predicates - Predicates to test the array against. Describes what the tested array should look like. @example ``` ow(['1', 2], ow.array.exactShape([ow.string, ow.number]));

(predicates: BasePredicate[])

Source from the content-addressed store, hash-verified

160 ```
161 */
162 exactShape(predicates: BasePredicate[]): this {
163 const shape = predicates as unknown as Shape;
164
165 return this.addValidator({
166 message: (_, label, message) => `${(message as string).replace('Expected', 'Expected element')} in ${label}`,
167 validator: object => exact(object as unknown as Record<string, unknown>, shape, undefined, true),
168 });
169 }
170}

Callers 7

absent.tsFile · 0.45
patchHotdogFunction · 0.45
nullable.tsFile · 0.45
array.tsFile · 0.45
object.tsFile · 0.45
validateFoodFunction · 0.45
typeTestsFunction · 0.45

Calls 2

exactFunction · 0.85
addValidatorMethod · 0.80

Tested by

no test coverage detected