catamphetamine / read-excel-file

Read *.xlsx files in a browser or Node.js. Parse to JSON with a strict schema.
https://catamphetamine.gitlab.io/read-excel-file/
MIT License
300 stars 52 forks source link

Cannot find name 'parsePhoneNumber'. #72

Closed ramya-sc closed 4 years ago

ramya-sc commented 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 ?

catamphetamine commented 4 years ago

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.