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

Method maxLength

source/predicates/array.ts:46–52  ·  view source on GitHub ↗

Test an array to have a maximum length. @param length - The maximum length of the array.

(length: number)

Source from the content-addressed store, hash-verified

44 @param length - The maximum length of the array.
45 */
46 maxLength(length: number): this {
47 return this.addValidator({
48 message: (value, label) => `Expected ${label} to have a maximum length of \`${length}\`, got \`${value.length}\``,
49 validator: value => value.length <= length,
50 negatedMessage: (value, label) => `Expected ${label} to have a minimum length of \`${length + 1}\`, got \`${value.length}\``,
51 });
52 }
53
54 /**
55 Test an array to start with a specific value. The value is tested by identity, not structure.

Callers 5

test.tsFile · 0.45
array.tsFile · 0.45
string.tsFile · 0.45
typed-array.tsFile · 0.45
typeTestsFunction · 0.45

Calls 1

addValidatorMethod · 0.80

Tested by

no test coverage detected