Closed ramya-sc closed 4 years ago
using "@angular/cli": "~8.3.17", and "read-excel-file": "^4.0.5",
'Mobile Number': { prop: 'MobNumber', type: Number, required: true, parse(value) { const number = parsePhoneNumber(value) if (!number) { throw new Error('invalid') } return number } }, 'Email ID': { prop: 'email', type: String, required: true, parse(value) { const email = parseEmail(value) if (!email) { throw new Error('invalid') } return email } }
How to write a custom validation for phone number and email, for email I need to check my own pattern ?
For phone number parsing and validation, one could use libphonenumber-js. For email validation, there's an "Email" type. Or one could use a custom validate(validate) function.
libphonenumber-js
"Email"
validate(validate)
using "@angular/cli": "~8.3.17", and "read-excel-file": "^4.0.5",
'Mobile Number': { prop: 'MobNumber', type: Number, required: true, parse(value) { const number = parsePhoneNumber(value) if (!number) { throw new Error('invalid') } return number } }, 'Email ID': { prop: 'email', type: String, required: true, parse(value) { const email = parseEmail(value) if (!email) { throw new Error('invalid') } return email } }
How to write a custom validation for phone number and email, for email I need to check my own pattern ?