A validator that can validate a string value.
Checks if the string's length is equal or lower than n.
const validator = avery.string().maxLength(5);console.log(validator.validate('hello').isOk()); // Output: trueconsole.log(validator.validate('hello world').isOk()); // Output: false Copy
const validator = avery.string().maxLength(5);console.log(validator.validate('hello').isOk()); // Output: trueconsole.log(validator.validate('hello world').isOk()); // Output: false
Checks if the string's length is equal or greater than n.
const validator = avery.string().minLength(5);console.log(validator.validate('hello').isOk()); // Output: trueconsole.log(validator.validate('hi').isOk()); // Output: false Copy
const validator = avery.string().minLength(5);console.log(validator.validate('hello').isOk()); // Output: trueconsole.log(validator.validate('hi').isOk()); // Output: false
const validator = avery.string();const result = validator.validate('hello');console.log(result.isOk()); // Output: true Copy
const validator = avery.string();const result = validator.validate('hello');console.log(result.isOk()); // Output: true
A validator that can validate a string value.