- required
- pattern
- minLength
Validators in field level
Validate.required("field"); // true
Validate.required(" "); // false
Validate.pattern("AZ", /[A-Z]/g); // true
Validate.pattern("boo", /[A-Z]/g); // false
Validate.minLength("Reza", 4); // true
Validate.minLength("Reza", 5); // false
const form = {
name: {
value: 'Foo',
validations: {
minLength: {
length: 4
},
pattern: {
pattern: /[A-Z]/g
},
},
},
};
const validator = new Validate(form);
validator.validate(); // [{ filed: 'name', errors: ["pattern","minLength"] }]
const form = {
name: {
value: 'Foo',
validations: {
minLength: {
length: 3
},
},
},
};
const validator = new Validate(form);
validator.validate(); // []