catamphetamine / read-excel-file

Read *.xlsx files in a browser or Node.js. Parse to JSON with a strict schema.

Home Page:https://catamphetamine.gitlab.io/read-excel-file/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot find name 'parsePhoneNumber'.

ramya-sc opened this issue · comments

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.