{"id":"959ba98a31219bca","repo":"sindresorhus/is","slug":"invalid-number-of-values","errorCode":null,"errorMessage":"Invalid number of values","messagePattern":"Invalid number of values","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"source/index.ts","lineNumber":993,"sourceCode":"\treturn getObjectType(value) === 'WeakRef';\n}\n\n// eslint-disable-next-line @typescript-eslint/no-restricted-types\nexport function isWeakSet(value: unknown): value is WeakSet<object> {\n\treturn getObjectType(value) === 'WeakSet';\n}\n\nexport function isWhitespaceString(value: unknown): value is Whitespace {\n\treturn isString(value) && /^\\s+$/v.test(value);\n}\n\ntype ArrayMethod = (function_: (value: unknown, index: number, array: unknown[]) => boolean, thisArgument?: unknown) => boolean;\n\nfunction predicateOnArray(method: ArrayMethod, predicate: Predicate, values: unknown[]) {\n\tvalidatePredicate(predicate);\n\n\tif (values.length === 0) {\n\t\tthrow new TypeError('Invalid number of values');\n\t}\n\n\treturn method.call(values, predicate);\n}\n\nfunction typeErrorMessage(description: AssertionTypeDescription, value: unknown): string {\n\treturn `Expected value which is \\`${description}\\`, received value of type \\`${is(value)}\\`.`;\n}\n\nfunction typeErrorMessageNot(description: AssertionTypeDescription, value: unknown): string {\n\treturn `Expected value which is not \\`${description}\\`, received value of type \\`${is(value)}\\`.`;\n}\n\ntype NotAssertionResult<Value, Forbidden, UnknownResult> = Exclude<Value, Forbidden> & ([unknown] extends [Value] ? UnknownResult : unknown);\n\ntype NotAssertion<Forbidden, UnknownResult = unknown> = <Value>(value: Value, message?: string) => asserts value is NotAssertionResult<Value, Forbidden, UnknownResult>;\n\n// eslint-disable-next-line @typescript-eslint/no-restricted-types","sourceCodeStart":975,"sourceCodeEnd":1011,"githubUrl":"https://github.com/sindresorhus/is/blob/7821031c66cdeb7256a0feb2d506535f9e84fcaf/source/index.ts#L975-L1011","documentation":"Thrown by the internal `predicateOnArray` helper (source/index.ts:989) when a multi-value check like `isAll(predicate)` / `isAny(predicate)` is evaluated with zero values. With no values, `every`/`some` would return a vacuous result (true/false with no evidence), so the library requires at least one value.","triggerScenarios":"Calling `isAll(predicate)` or `isAny(predicate)` in evaluator mode with no values after the predicate — often because a spread of an empty array supplied the values: `isAll(is.string, ...items)` where `items.length === 0`.","commonSituations":"Spreading a dynamically-built list that happens to be empty (empty API response, filtered-out results); forgetting the value arguments entirely and expecting a curried guard back (only the predicates-array overload curries); loops that call the check before data loads.","solutions":["Guard the call site: check `items.length > 0` before spreading them into `isAll`/`isAny`, and decide explicitly what an empty list means for your logic.","Pass at least one value argument after the predicate.","If you wanted a reusable guard rather than an immediate check, use the array form `isAll([pred1, pred2])` which returns a type guard."],"exampleFix":"// before\nisAll(is.string, ...maybeEmpty); // throws when maybeEmpty is []\n\n// after\nif (maybeEmpty.length > 0 && isAll(is.string, ...maybeEmpty)) {\n  // all strings\n}","handlingStrategy":"validation","validationCode":"if (values.length === 0) {\n  throw new TypeError('Provide at least one value to check');\n}","typeGuard":"function hasValues<T>(arr: T[]): arr is [T, ...T[]] {\n  return arr.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Check `values.length > 0` before spreading a dynamic array into `is.all(...)`/`is.any(...)`-style variadic calls","Handle the empty-collection case explicitly in your own code (decide whether empty means pass or fail) instead of delegating it to the library","Avoid spreading possibly-empty results of `.filter()`/`.map()` directly into the call"],"tags":["validation","empty-array","predicate"],"analyzedSha":"7821031c66cdeb7256a0feb2d506535f9e84fcaf","analyzedAt":"2026-07-31T18:34:06.268Z","schemaVersion":2}