validateIntegerFrom

It resolves the integer value if it meets the criteria of being higher than a specific point. This point is called 'from'. For example, if from is 10, then the integer 9 would be invalid whereas 11 would be valid. Any integer value equal or greater than 'from' will validate and resolve.
Please, note that the tuple parameter isn't optional, if you don't intend to use it, assign it undefined.
Parameter ListReturnsRejection Errors
  • supposedInteger: number
  • tuple: Array
  • from: number
Promise<number || Array>
Related FunctionsFunction Signature
function validateIntegerFrom(supposedInteger, tuple, from): Promise<number || Array>
1 2 3 4 5 import { validateIntegerFrom } from "puddy-m/lib/validators/complexValidators"; validateIntegerFrom(100, null, 99).then((validatedInteger) => console.log(validatedInteger) ); // prints 100
1 2 3 4 5 6 import { validateString } from "puddy-m/lib/validators"; import { validateIntegerFrom } from "puddy-m/lib/validators/complexValidators"; validateIntegerFrom(100, [], 99) .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 { validateIntegerFrom } from "puddy-m/lib/validators/complexValidators"; const run = async () => { try { const validatedInteger = await validateIntegerFrom(100, null, 99); 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 { validateIntegerFrom } from "puddy-m/lib/validators/complexValidators"; const run = async () => { try { const validatedInteger = await validateIntegerFrom(99, null, 100); console.log(validatedInteger); } catch (e) { // Throws IntegerValidationErrorFromValue console.log(e); } }; run();