validateIntegerUntilLimit

This function validates the integer that is lower or equal the limit parameter. For example, if limit is 10, the integer 9 would be valid wheras the 10 would be invalid.
Please, note that the tuple parameter isn't optional, so if you don't intend to use, it, assign it undefined.
Parameter ListReturnsRejection Errors
  • supposedInteger: *
  • tuple: Array
  • limit: number
Promise<number || Array>
Related FunctionsFunction Signature
function validateIntegerUntilLimit(supposedInteger, tuple, integer): Promise<number || Array>
1 2 3 4 5 import { validateIntegerUntilLimit } from "puddy-m/lib/validators/complexValidators"; validateIntegerUntilLimit(100, null, 101).then((validatedInteger) => console.log(validatedInteger) ); // prints 100
1 2 3 4 5 6 import { validateString } from "puddy-m/lib/validators"; import { validateIntegerUntilLimit } from "puddy-m/lib/validators/complexValidators"; validateIntegerUntilLimit(100, [], 101) .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 { validateIntegerUntilLimit } from "puddy-m/lib/validators/complexValidators"; const run = async () => { try { const validatedInteger = await validateIntegerUntilLimit(100, null, 101); console.log(validatedInteger); // prints 100 } catch (e) { console.log(e); } }; run();
1 2 3 4 5 6 7 8 9 10 11 12 13 14 import { validateIntegerUntilLimit } from "puddy-m/lib/validators/complexValidators"; const run = async () => { try { const validatedInteger = await validateIntegerUntilLimit(100, null, 99); console.log(validatedInteger); } catch (e) { // Throws IntegerValidationErrorToValue console.log(e); } }; run();