validateNegativeIntegers
Description
It resolves if the parameter is an integer and it's lower than 0 (it doesn't include 0).
Parameter List | Returns | Rejection Errors |
---|---|---|
| Promise<number || Array> | |
Related Functions | Function Signature | |
function validateNegativeIntegers(supposedPositiveInteger[, tuple]): Promise<number || Array> |
Examples
1
2
3
4
5
import { validateNegativeIntegers } from "puddy-m/lib/validators/complexValidators";
validateNegativeIntegers(-100).then((validatedInteger) =>
console.log(validatedInteger)
); // prints -100
1
2
3
4
5
6
import { validateString } from "puddy-m/lib/validators";
import { validateNegativeIntegers } from "puddy-m/lib/validators/complexValidators";
validateNegativeIntegers(-100, [])
.then((tuple) => validateString("string", tuple))
.then((tuple) => console.log(tuple)); // prints [-100, 'string']
1
2
3
4
5
6
7
8
9
10
11
12
13
import { validateNegativeIntegers } from "puddy-m/lib/validators/complexValidators";
const run = async () => {
try {
const validatedNegativeInteger = await validateNegativeIntegers(-100);
console.log(validatedNegativeInteger); // prints -100
} catch (e) {
console.log(e);
}
};
run();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { validateNegativeIntegers } from "puddy-m/lib/validators/complexValidators";
const run = async () => {
try {
const validatedNegativeInteger = await validateNegativeIntegers(100);
console.log(validatedNegativeInteger);
} catch (e) {
// Throws an NegativeIntegersError
console.log(e);
}
};
run();