validateNotUndefined

It resolves if the parameter passed is anything but undefined, else it will reject.
Parameter ListReturnsRejection Errors
  • supposedNotUndefinedArg: *
  • tuple: Array (optional)
Promise<* || Array>
Related FunctionsFunction Signature
function validateNotUndefined(supposedNotUndefinedArg[, tuple]): Promise<* || Array>
1 2 3 import { validateNotUndefined } from "puddy-m/lib/validators"; validateNotUndefined("This is not undefined.").then(console.log); // prints 'This is not undefined.'
1 2 3 4 5 import { validateNotUndefined, validateString } from "puddy-m/lib/validators"; validateNotUndefined("string", []) .then((tuple) => validateString("foo", tuple)) .then(console.log); // prints ['string', 'foo']
1 2 3 4 5 6 7 8 9 10 11 12 13 14 import { validateNotUndefined } from "puddy-m/lib/validators"; const run = async () => { try { const notUndefined = await validateNotUndefined("not undefined"); console.log(notUndefined); // prints 5 } catch (e) { console.log(e); } }; run();
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import { validateNotUndefined } from "puddy-m/lib/validators"; const run = async () => { try { const notUndefined = await validateNotUndefined(undefined); console.log(notUndefined); // Will throw since arg is undefined } catch (e) { // Throws NotUndefinedValidationError console.log(e); } }; run();