validateFields
import validate, {
form, required, length, range
} from 'strickland';
const personValidator = form({
firstName: [
required(),
length({minLength: 2, maxLength: 20})
],
lastName: [
required(),
length({minLength: 2, maxLength: 20})
],
birthYear: range({min: 1900, max: 2018})
});
// Initialize the person with only a firstName
let person = {
firstName: 'Stanford'
};
// Validate the firstName field
let result = validate(personValidator, person, {
form: {
fields: ['firstName']
}
});Last updated