Marketto / codice-fiscale-utils

Utility to handle Italian Codice Fiscale
MIT License
25 stars 11 forks source link

Uncaught Error while testing a valid name #105

Closed nicoblg closed 5 months ago

nicoblg commented 7 months ago

Environment:

Platform [ ] nodeJs [ x] Web/Browser

Issue description: Testing a FirstName or a LastName wich contains two names with the first containing an apostrophe ( ' ) results in Uncaught Error: Provided name is not valid, only letters, diacritics and apostrophe allowed. This does not happen if the apostrophe is part of the second name. I did not try on more than two names but it could be possible that there's something wrong there too.

Steps to reproduce the problem:

  1. Test a name using function codiceFiscale({firstName: name,}).test(cf) where the name is for example Noe' Fabio.
  2. See error: Uncaught Error: Provided name is not valid, only letters, diacritics and apostrophe allowed at ea.cfFirstName (pattern.class.ts:68:23) at pattern.class.ts:248:36 at ea.codiceFiscale (pattern.class.ts:255:43)
  3. Trying with the same name with the apostrophe inverted work as expected. eg: Noe Fabio'

Expected behavior Function should return if the name is valid looking at the CF.

Marketto commented 5 months ago

Try one of these:

Aphostrophe + space is not allowed This library is for CF not for names