validateAllArgs
Description
It resolves if all args passed in the parameter list validates against the validateFunction passed in the first parameter. This function is to be used as a helper for the following functions:
If you would like to use this function, you need to create your own promise based validation function.
Parameter List | Returns | Rejection Errors |
---|---|---|
| Promise<Array<*>> | |
Related Functions | Function Signature | |
function validateAllArgs(validateFunction, ...args): Promise<Array<*>> |
Examples
1
2
3
4
import { validateAllArgs } from "puddy-m/lib/validators/complexValidators";
import { validateBoolean } from "puddy-m/lib/validators";
validateAllArgs(validateBoolean, true, true, false, true).then(console.log); // [true, true, false, true]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { validateAllArgs } from "puddy-m/lib/validators/complexValidators";
import { validateString } from "puddy-m/lib/validators";
// It also works with await.
const f = async () => {
const validatedArgs = await validateAllArgs(
validateString,
"true",
"",
"78",
"str"
);
console.log(validatedArgs); // ["true", "", "78", "str"]
};
f();