validateNotNull

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