@jrock2004 wrote:
So I am using ember cp validations and I want to enable/disable a rule based off of a property that is set via a component
// Model/Customer
const Validations = buildValidations({ firstName: validator('presence', { message: "Please enter your first name", presence: true }), lastName: validator('presence', { message: "Please enter your last name", presence: true }), email: [ validator('presence', { message: "Please enter an email address", presence: true }), validator('format', { message: "Please enter a valid email address", type: 'email' }) ], cellPhone: [ validator('presence', { disabled: readOnly('shouldCheckCellPhone'), message: "Please enter a phone number", presence: true }), validator('format', { disabled: readOnly('shouldCheckCellPhone'), message: "Please enter a valid phone number", type: 'phone' }) ] }); export default DS.Model.extend(HasManyQuery.ModelMixin, Validations, { email: DS.attr('string'), firstName: DS.attr('string'), cellPhone: DS.attr('string'), lastName: DS.attr('string'), shouldCheckCellPhone: false, });
Here is my component
didReceiveAttrs() { this._super(...arguments); this.set('model.shouldCheckCellPhone', !this .get('requireMobilePhoneCarrier')); },
Thoughts?
Posts: 1
Participants: 1