I would like users to optionally insert an email using ember-cp-validations:
const Validations = buildValidations({
managerEmail: {
validators: [
validator('presence', null), // means it can be optional when used alone
validator('format', { type: 'email' })
]
}
});
But it still requires an email and won't accept an empty field. How can I make it optional?
Your definition should be as follows to allow blank (to make it optional):
const Validations = buildValidations({
managerEmail: validator('format', { type: 'email', allowBlank:true})
});