This is one of those things I would love to do myself, but I simply have no time to pursue it. So I thought that I would throw this package idea out in the community, and hope someone with better time would want to make it.
Phone number validation.
I work at a company with about 50.000 daily customers hitting our Elm based frontend. When purchasing a train ticket (which is the service we provide) the user is allowed to pay using their phone, or receive a copy of a receipt on their phone. For this, we need to validate their phone number.
The current way we do this is to import this js library and use it through ports: https://github.com/googlei18n/libphonenumber
It works, but involves a lot of ceremony. It also increases the JS asset size by A LOT when we mostly only care about Norwegian phone numbers.
If anyone were to create a Elm library with the same features, it would quickly find its way into our applications.
I might have some time tomorrow. Can you tell me more about the exact features you require? libphonenumber is huge; it might make sense to focus the Elm app, to only be able to validate if a number might be a phone number or not. (And keep the formatting, geolocation, etc. for other packages)
We specifically need to know:
- Is it a norwegian phone number?
- Is it a mobile/cellular phone number?
We don’t need formatting or stuff like that. Just validation.
If I remember correctly from scanning through libphonenumber, it has all required definitions in a .xml file. Maybe one could write a script that generates a .elm file from that .xml, and use that as a basis for other packages.
Kind of like
justinmimbs/timezone-data provides time zone information for
Hello! I was wondering if you had begun work on this?
Second this! (But slightly different use case…)
We use use Cleave.js for input formatting.
We use is for SSN, Phone and Currency. Note the we just use cleave for input re-formatting, not actual validation (but it does act as a validator in that, for example, it will not allow non-numeric characters in the input.)
Part of the reason we haven’t moved to Elm 0.19 is we are using a native module for this. (I’m sure we could move this to ports, not trying to open up that conversation…) but would love an Elm native form input formatter!
While you wait, this is purportedly smaller and is one I used through a port recently: https://www.npmjs.com/package/awesome-phonenumber
Would also love to see an elm package version appear and then could knock out some unwelcome JS from the app.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.