validateStringLengthGreaterThan

It validates the str parameter if its length is greater than the value specified in the len paramameter.
Note: Equal lenghts would fall under rejection (use validateStringLengthGreaterEqual instead).
Parameter ListReturnsRejection Errors
  • str: string
  • len: number
  • tuple: Array (optional)
Promise<string || Array>
Related FunctionsFunction Signature
function validateStringLengthGreaterThan(str, len[, tuple]): Promise<string || Array>
1 2 3 import { validateStringLengthGreaterThan } from "puddy-m/lib/validators/complexValidators"; validateStringLengthGreaterThan("foo", 2).then(console.log); // prints 'foo'
1 2 3 4 5 6 import { validateStringLengthGreaterThan } from "puddy-m/lib/validators/complexValidators"; import { validateString } from "puddy-m/lib/validators"; validateStringLengthGreaterThan("fizz", 1, []) .then((tuple) => validateString("foo", tuple)) .then(console.log); // prints ['fizz', 'foo']
1 2 3 4 5 6 7 8 9 10 11 12 13 import { validateStringLengthGreaterThan } from "puddy-m/lib/validators/complexValidators"; const run = async () => { try { const validString = await validateStringLengthGreaterThan("string", 2); console.log(validString); // prints 'string' } catch (e) { console.log(e); } }; run();
1 2 3 4 5 6 7 8 9 10 11 12 13 14 import { validateStringLengthGreaterEqual } from "puddy-m/lib/validators/complexValidators"; const run = async () => { try { const invalidString = await validateStringLengthGreaterThan("foo", 3); console.log(invalidString); // Because string length is not greater than 3, it will throw } catch (e) { // Throws StringLengthGreaterThanError console.log(e); } }; run();