ng2-validation icon indicating copy to clipboard operation
ng2-validation copied to clipboard

Libphonenumber support

Open dustinblanchard opened this issue 7 years ago • 9 comments

It would be awesome to see google's libphonenumber included for phone validation. The AsYouTypeFormatter would be really great to have here.

dustinblanchard avatar Nov 22 '16 22:11 dustinblanchard

With latest angular/ng2-validation importing Phone validator throws error: <input phone="CN" ...> XHR error (404 Not Found) loading http://localhost:3000/libphonenumber-js

Versions:

"@angular/core": "~4.0.0",
"@angular/forms": "~4.0.0",
"ng2-validation": "^4.1.0",

latobibor avatar Apr 26 '17 07:04 latobibor

When updating ng2-validation from 3.9.1 I am getting the same error @latobibor described.

Error: (SystemJS) XHR error (404 Not Found) loading http://localhost/accounts_payable/libphonenumber-js

Versions:

"@angular/core": "^4.0.2",
"@angular/forms": "^4.0.2",
"ng2-validation": "^4.1.0",

dhniels avatar Apr 26 '17 23:04 dhniels

I get the same 404 error when I try the latest 4.2.0 version.

Versions:

`
"@angular/core": "~2.4.0",
"@angular/forms": "~2.4.0",
"ng2-validation": "^4.2.0",
`

I can also confirm that when i downgraded to the version mentioned above (3.9.1), it starts working.

mgroetan avatar Jun 30 '17 15:06 mgroetan

@mgroetan you can resolve this by installing libphonenumber-js

install it using npm install libphonenumber-js --save or add "libphonenumber-js": "^0.4.18" to your package.json

dhniels avatar Jun 30 '17 16:06 dhniels

@dhniels That doesn't help at all - same error. You see, when I installed the validation package, it downloaded the phone number package as well. I could very well see the folder/files within "node_modules". When I install "libphonenumber-js" manually as you suggest, it effectively doesn't do anything (other than add it to "package.json"), as the package has already been downloaded.

Log from install of "ng2-validation" (backticks replaced with apostrophes):

`'-- [email protected]
  '-- [email protected]
    +-- [email protected]
    |'-- [email protected]
    +-- [email protected]
    '-- [email protected]
      '-- [email protected]`

mgroetan avatar Jun 30 '17 17:06 mgroetan

@mgroetan Hm, not sure then. I had the same error and assumed since the new version was requiring this dependency that installing it would resolve the error (which it did) so its now working for me. You must have something else going on. I wonder if upgrading your angular to version 4 would resolve it? Sorry that wasn't more useful. Hopefully the author will see this issue and respond with a definitive answer since its been open a while.

dhniels avatar Jun 30 '17 17:06 dhniels

Here we install libphonenumber as a dependency in the project too, maybe this can help u

guilhermejcgois avatar Jun 30 '17 21:06 guilhermejcgois

I add this mapping for system.config.js: 'libphonenumber-js' : 'npm:libphonenumber-js/bundle/libphonenumber-js.min.js' and it helps

brachi-wernick avatar Jul 13 '17 08:07 brachi-wernick

Oh yeah @mgroetan that could've been your problem. i forgot to add that. you do indeed need to add it to your systemjs config, see above comment

dhniels avatar Jul 13 '17 14:07 dhniels