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));