I have an order model that I’m collecting data for over a multi-page form. I’ve created some validations like this:
const Validations = buildValidations({
// these should only be used when we’re on checkout.info route
name: validator('presence', true),
email: [
validator('presence', true),
validator('format', { type: 'email' })
],
// these should only be used when we’re on checkout.shipping route
address1: validator('presence', true),
address2: validator('presence', true),
city: validator('presence', true),
});
My model is set up to use them like this:
export default Model.extend(Validations, {
// model set-up in here
})
What I’d like to happen is for it to only validate name and email when I’m on checkout.info and to validate address1, address2 and city when I’m on checkout.shipping.
How might I go about achieving this?
Aucun commentaire:
Enregistrer un commentaire