Closed hongyuan1306 closed 7 years ago
I have a form in which I want the user to input at least one of his mobile number and phone number.
I tried to add a custom validator like the one below:
Validator.register( 'notbothempty', function(val, req) { const other = this.validator.input[req] return (val !== undefined && val !== null && val !== '') || (other !== undefined && other !== null && other !== '') } )
And create a schema like:
strategy.createSchema({ mobile: 'mobile|notbothempty:phone', phone: 'phone' })
This does not work however. With the fields empty, the custom validator is not invoked.
How can this sort of validation be performed?
Sorry this question is more appropriate for validatorjs
I have a form in which I want the user to input at least one of his mobile number and phone number.
I tried to add a custom validator like the one below:
And create a schema like:
This does not work however. With the fields empty, the custom validator is not invoked.
How can this sort of validation be performed?