overEvery()
overEvery<
T>(predicates): (value) =>boolean
Creates a function that checks if all of the predicates return truthy when invoked with the arguments it receives.
DEPRECATED
Use predicates.every(fn => fn(value)) directly instead.
Type Parametersβ
T: Tβ
The type of the value to check.
Parametersβ
predicates: (value) => boolean[]β
The predicates to check.
Returnsβ
A function that returns true if all predicates pass.
See Alsoβ
Sinceβ
2.0.0
Also known asβ
allPass (Ramda) Β· overEvery (Lodash, es-toolkit) Β· β (Remeda, Radashi, Effect, Modern Dash, Antfu)
Exampleβ
// β Deprecated approach
const isPositiveEven = overEvery([n => n > 0, n => n % 2 === 0]);
isPositiveEven(4); // => true
isPositiveEven(-2); // => false
// β
Recommended approach
const predicates = [(n: number) => n > 0, (n: number) => n % 2 === 0];
const isPositiveEven = (n: number) => predicates.every(fn => fn(n));
isPositiveEven(4); // => true
isPositiveEven(-2); // => false
How it works?β
Creates a function that checks if all predicates return truthy.
Deprecated: Use Array.every() with predicates.
Native Equivalentβ
// β overEvery([fn1, fn2])(value)
// β
[fn1, fn2].every(fn => fn(value))
Use Casesβ
Combine predicates with AND πβ
Check if all predicates pass.
const predicates = [
(n: number) => n > 0,
(n: number) => n % 2 === 0
];
const isPositiveEven = (n: number) => predicates.every(fn => fn(n));
isPositiveEven(4); // true
isPositiveEven(-2); // false
Validate multiple rulesβ
Ensure value passes all validation rules.
const rules = [
(s: string) => s.length >= 8,
(s: string) => /[A-Z]/.test(s),
(s: string) => /[0-9]/.test(s)
];
const isValidPassword = (s: string) => rules.every(r => r(s));