validateStringLengthGreaterEqual
Description
It validates the str parameter if its length is greater or equal the value specified in the len paramameter.
PS: Equal lenghts would fall under resolution.
Parameter List | Returns | Rejection Errors |
---|---|---|
| Promise<string || Array> | |
Related Functions | Function Signature | |
function validateStringLengthGreaterEqual(str, len[, tuple]): Promise<string || Array> |
Examples
1
2
3
import { validateStringLengthGreaterEqual } from "puddy-m/lib/validators/complexValidators";
validateStringLengthGreaterEqual("foo", 3).then(console.log); // prints 'foo'
1
2
3
4
5
6
import { validateStringLengthGreaterEqual } from "puddy-m/lib/validators/complexValidators";
import { validateString } from "puddy-m/lib/validators";
validateStringLengthGreaterEqual("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 { validateStringLengthGreaterEqual } from "puddy-m/lib/validators/complexValidators";
const run = async () => {
try {
const validString = await validateStringLengthGreaterEqual("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 validateStringLengthGreaterEqual("foo", 5);
console.log(invalidString); // Because string length is not greater than 5, it will throw
} catch (e) {
// Throws StringLengthGreaterEqualError
console.log(e);
}
};
run();