validator.js icon indicating copy to clipboard operation
validator.js copied to clipboard

New validation (isName)

Open MindRapist opened this issue 8 years ago • 6 comments

Ok so not really an issue - sorry about that Im not familliar with GitHub yet but I didnt find another way to post this. I forked validator and I created a new file which I believe will be useful to this repo take a look here.

I hope people find this useful and I'd love to hear what's on your mind about this. Best regards!

MindRapist avatar Nov 16 '18 03:11 MindRapist

Not really sure about this request but would love to hear what the rest of the team says.

profnandaa avatar Nov 16 '18 08:11 profnandaa

Good idea, but I don't think it's much better than removing the spaces from the string then using isAlpha(). Your method also ignores a lot of cases where names can have more than 2 parts.

linkinmedo avatar Nov 18 '18 22:11 linkinmedo

Something to keep in mind when trying to validate names: https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/

fkm avatar Jan 13 '19 14:01 fkm

@profnandaa @linkinmedo Some states in the US allow numbers in the names, so this feature would just be like isAlphanumeric with option like {ignore_whitespace : true}.

parasg1999 avatar May 26 '20 20:05 parasg1999

Something to add - we were hoping to use this for name validation and ran into the same issues we see above. The white spaces and characters were less the issue, though, than punctuation (e.g. "O'Hara" or "Hyphenated-Lastname"). We thought of requesting an "isAlphaDeluxe()", where the dev could pass in an array of punctuation marks that will also be permitted. It didn't really amount to more than stripping the allowed punctuation from the string and running isAlpha(), or isAlphanumeric() on it. So that, along with ignoring white space, resolved our issues. Hope that helps!

joellis13 avatar Aug 03 '21 15:08 joellis13

closing this issue, as discussed above

pano9000 avatar Jan 23 '23 00:01 pano9000