8 ms·
A coworker once implemented a name validation regex that would reject his own name. It still mystifies me how much convincing it took to get him to make it less
by jtvjan 2y ago
A coworker once implemented a name validation regex that would reject his own name. It still mystifies me how much convincing it took to get him to make it less strict.
- croes 2y agoIs name validation even possible?
- armada651 2y agoYes, it is essential when you want to avoid doing business with customers who have invalid names.
- ryandrake 2y agoYou joke, but when a customer wants to give your company their money, it is our duty as developers to make sure their names are valid. That is so business critical!
- xtiansimon 2y agoIn legitimate retail, take the money, has always been the motto. That said, recently I learned about monetary policy in North Korea and sanctions on the import of luxury goods. Why Nations Fail (2012) by Daron Acemoglu and James Robinson https://en.wikipedia.org/wiki/United_Nations_Security_Council_Resolution_1718 https://en.wikipedia.org/wiki/United_Nations_Security_Counci...
- Muromec 2y agoIt's not just business necrssary, it's also mandatory to do rigjt under gdpr
- Diti 2y agoWhat are “invalid names” in this context? Because, depending on the country the person was born in, a name can be literally anything, so I’m not sure what an invalid name looks like (unless you allow an `eval` of sorts).
- dgoldstein0 2y agoObligatory xkcd https://xkcd.com/327/ https://xkcd.com/327/
- Muromec 2y agoThe non-joke answer for Europe is extened Latin, dashes, spaces and apostrophe sign, separated into two (or three) distinct ordered fields. Just because it's written in a different script originally, doesn't mean it will printed only with that on your id in the country of residence or travel document issued at home. My name isn't written in Latin characters and it's fine. I know you can't even try to pronounce them, so I have it spelled out in above mentioned Latin script.
- throw_a_grenade 2y agoNon-joke answer for Europe is at least Latin, Greek or Cyrillic (български is already one of the official EU languages!). No reason to treat them differently, just don't allow for mixing them so you won't get homoglyphs. EURid (.eu-NIC) gets it mostly right I believe.
- account42 2y agoThe non-theoretical answer for Europe is just Latin because the names need to eventually be read by people who don't know Greek or Cyrillic.
- jandrese 2y agoWhat if your customer is the artist formerly known as Prince or even X Æ A-12 Musk?
- chungy 2y agoPrince: "Get over yourself and just use your given name." (Shockingly, his given name actually is Prince; I first thought it was only a stage name) Musk: Tell Elon to get over his narcissism enough to not use his children as his own vanity projects. This isn't just an Elon problem, many people treat children as vanity projects to fuel their own narcissism. That's not what children are for. Give him a proper name. (and then proceed to enter "X Æ A-12" into your database, it's just text...)
- jandrese 2y agoSure it is just text, but the context is someone who wrote a isValidHumanName() function.
- rsynnott 2y agoPrince is still mostly screwed, even without spurious validation; Unicode doesn't allow personal symbols. Some discussion here: https://www.unicode.org/mail-arch/unicode-ml/Archives-Old/UML019/0610.html https://www.unicode.org/mail-arch/unicode-ml/Archives-Old/UM...
- majkinetor 2y agoSure it is. Context matters. For example, in clone wars.
- poizan42 2y agoYes, it's easy bool ValidateName(string name) => true; (With the caveat that a name might not be representable in Unicode, in which case I dunno. Use an image format?)
- arsome 2y agoname.Length > 0 is probably pretty safe.
- tomxor 2y agoWhat if my name is
- chuckadams 2y agoSlim Shady?
- pridkett 2y agoThat only works if you’re concatenating the first and last name fields. Some people have no last name and thus would fail this validation if the system had fields for first and last name.
- cluckindan 2y agosome people have no name at all
- exitb 2y agoAny notable examples apart from young children and Michael Scott that one time?
- ndsipa_pomu 2y agoI've been compiling a list of them:
- rsynnott 2y agoNo, but it doesn’t stop people trying.
- gmuslera 2y agoYou may not want Bobby Tables in your system.
- malfist 2y agoIf you're prohibiting valid letters to protect your database because you didn't parametrize your queries, you're solving the problem from the wrong end
- gmuslera 2y agoThere might be more than just 2 ends. And some of them may not be fixable by you.
- account42 2y agoThis is all well and good until the company looses real money becaus some other system you are interfacing with got compromised because of your attitude and fingers start being pointed. Defense in depth is a thing.
- crazygringo 2y agoIf you just use the {Alphabetic} Unicode character class (100K code points), together with a space, hyphen, and maybe comma, that might get you close. It includes diacritics. I'm curious if anyone can think of any other non-alphabetic characters used in legal names around the world, in other scripts? I wondered about numbers, but the most famous example of that has been overturned: "Originally named X Æ A-12, the child (whom they call X) had to have his name officially changed to X Æ A-Xii in order to align with California laws regarding birth certificates." (Of course I'm not saying you should do this. It is fun to wonder though.)
- nicoburns 2y agoApostrophe is common in surnames in parts of the world.
- poizan42 2y agoYou forgot apostrophe as is common in Irish names like O’Brien.
- bloak 2y agoYes, though O’Brien is Ó Briain in Irish, according to Wikipedia. I think the apostrophe in Irish names was added by English speakers, perhaps by analogy with "o'clock", perhaps to avoid writing something that would look like an initial. There are also English names of Norman origin that contain an apostrophe, though the only example I can think of immediately is the fictional d'Urberville.
- gus_massa 2y agoComma or apostrophe, like in d'Alembert ? (And I have 3 in my keyboard, I'm not sure everyone is using the same one.)
- ahazred8ta 2y agoMrs. Keihanaikukauakahihuliheekahaunaele only had a string length problem, but there are people with a Hawaiian ʻokina in their names. U+02BB
- zarzavat 2y agoPresumably there aren't any people with control characters in their name, for example.
- kijin 2y agoChallenge accepted, I'll try to put a backspace and a null byte in my firstborn's name. Hope I don't get swatted for crashing the government servers.
- cobbzilla 2y agoWatch as someone names themselves the bell character, “^G” (ASCII code 7) [1] When they meet people, they tell them their name is unpronounceable, it’s the sound of a PC speaker from the late 20th century, but you can call them by their preferred nickname “beep”. In paper and online forms they are probably forced to go by the name “BEL”. [1] https://en.wikipedia.org/wiki/Bell_character https://en.wikipedia.org/wiki/Bell_character
- emmelaich 2y agoOr Derek <wood dropping on desk> https://www.youtube.com/watch?v=hNoS2BU6bbQ https://www.youtube.com/watch?v=hNoS2BU6bbQ
- pavel_lishin 2y agoI thought this was going to be a link to the Key & Peele sketch: https://youtu.be/gODZzSOelss?t=180 https://youtu.be/gODZzSOelss?t=180
- Polizeiposaune 2y agoThe interaction brings to mind Grzegorz Brzęczyszczykiewicz: https://www.youtube.com/watch?v=AfKZclMWS1U https://www.youtube.com/watch?v=AfKZclMWS1U (from the Polish comedy film "How I Unleashed World War II")
- Izkata 2y agoIt's not exactly a bell, but there are clicks: https://en.wikipedia.org/wiki/Click_consonant https://en.wikipedia.org/wiki/Click_consonant https://www.reddit.com/r/Damnthatsinteresting/comments/1614ka2/their_names_have_got_a_click_in_it_damm_thats_cool/ https://www.reddit.com/r/Damnthatsinteresting/comments/1614k...
- nkrisc 2y agoIt is if you first provide a complete specification of a “name”. Then you can validate if a name is compliant with your specification.
- GrantMoyer 2y agoValid names are those which terminate when run as Python programs.
- Muromec 2y agoIt's super easy actually. Name consists of three parts -- Family Name, Given Name and Patronymic, spelled using Ukrainian Cyrillic. You can have a dash in the Family name and apostrophe is part of Cyrillic for this purposes, but no spaces in any of the three. If are unfortunate enough to not use Cyrillic (of our variety) or Patronymics in the country of your origin (why didn't you stay there, anyway), we will fix it for you, mister Нкріск. If you belong to certain ethnic groups who by their custom insist on not using Patronymics, you can have a free pass, but life will be difficult, as not everybody got the memo really. No, you can not use Matronimyc instead of Patronymic, but give us another 30 years of not having a nuclear war with country name starting with "R" and ending in "full of putin slaves si iiia" and we might see to that. Unless of course the name is not used for official purposes, in which case you can get away with First-Last combination. It's really a non issue and the answer is jurisdiction bound. In most of Europe extented Latin set is used in place of Cyrillic (because they don't know better), so my name is transliterated for the purposes of being in the uncivilized realms by my own government. No, I can't just use Л and Я as part of my name anywhere here.
- ValentinA23 2y agoDon't validate names, use transliteration to make them safe for postal services (or whatever). In SQL this is COLLATE, in the command line you can use uconv: >echo "'Lódź'" | uconv -f "UTF-8" -t "UTF-8" -x "Latin-ASCII" >'Lodz'
- notanote 2y agoThe name of the city has the L with stroke (pronounced as a W), so it’s Łódź.
- poincaredisk 2y agoAnd the transliteration in this case is so far from the original that it's barely recognisable for me (three out of four characters are different and as a native I perceive Ł as a fully separate character, not as a funny variation of L)
- Muromec 2y agoThe fact that it's pronounced as Вуч and not Лодж still triggers me.
- pavel_lishin 2y agoI just looked up the Russian wikipedia entry for it, and it's spelled "Лодзь", but it sounds like it's pronounced "Вуджь", and this fact irritates the hell out of me. Why would it be transliterated with an Л? And an О? And a з? None of this makes sense.
- Muromec 2y agoIt's a general pattern of what russia does to names of places and people, which is aggressively imposing their own cultural paradigm (which follows the more general general pattern). You can look up your civil code provisions around names and ask a question or two of what historical problem they attempt to solve.
- barryrandall 2y agoAnything is possible with enough qualifiers and caveats.
- perching_aix 2y agoIn certain cultures yes. Where I live, you can only select from a central, though frequently updated, list of names when naming your child. So theoretically only (given) names that are on that list can occur. Family names are not part of this, but maybe that exists too elsewhere. I don't know how people whose name has been given to them before this list was established is handled however. An alternative method, which is again culture dependent, is to use virtual governmental IDs for this purpose. Whether this is viable in practice I don't know, never implemented such a thing. But just on the surface, should be.
- tomtomtom777 2y agoThis assumes every resident is born and registered in said country which is a silly assumption. Surely, any service only catered only to "naturally born citizen" is discriminatory and illegal?
- marcus_holmes 2y agoI read that Iceland asks people to change their names if they naturalise there (because of the -sson or -dottir surname suffix). But your point stands - not everyone in the system will follow this pattern.
- lmm 2y ago> Surely, any service only catered only to "naturally born citizen" is discriminatory and illegal? No, that's also a question that is culturally dependent. In some contexts it's normal and expected.
- perching_aix 2y agoObviously, foreigners just living or visiting here will not have our strictly local names (thinking otherwise is what would be "silly"). Locals (people with my nationality, so either natural or naturalized citizens) will (*). (*) I read up on it though, and it seems like exceptions can be requested and allowed, if it's "well supported". Kinda sours the whole thing unfortunately. > is discriminatory and illegal? Checked this too (well, using Copilot), it does appear to be illegal in most contexts, although not all. But then, why would you want to perform name verification specific to my culture? One example I can think of is limiting abuse on social media sites for example. I vaguely recall Facebook being required to do such a thing like a decade ago (although they definitely did not go about it this way clearly).
- michaelt 2y agoThere are of course some people who'll point you to a blog post saying no validation is possible. However, for every 1 user you get whose full legal name is bob@example.com you'll get 100 users who put their e-mail into the name field by accident And for every 1 user who wants to be called e.e. cummings you'll get 100 who just didn't reach for the shift key and who actually prefer E.E. Cummings. But you'll also get 100 McCarthys and O'Connors and al-Rahmans who don't need their "wrong" capitalisation "fixed" thank you very much. Certainly, I think you can quite reasonably say a name should be comprised of between 2 and 75 characters, with no newlines, nulls, emojis, leading or trailing spaces, invalid unicode code points, or angle brackets.
- throw310822 2y agoI know multiple developers who would just say "well it's their fault, they have to change name then".
- MrJohz 2y agoI worked with an office of Germans who insisted that ASCII was sufficient. The German language uses letters that cannot be represented in ASCII. In fairness, they mostly wanted stuff to be in English, and when necessary, to transliterate German characters into their English counterparts (in German there is a standardised way of doing this), so I can understand why they didn't see it was necessary. I just never understood why I, as the non-German, was forever the one trying to convince them that Germans would probably prefer to use their software in German...
- sandreas 2y agoYou should have asked how they would encode the german currency sign (€ for euro) in ASCII or its german counterpart latin1/iso-8859-1... It's not possible. However I bet they would argument to use iso-8859-15 (latin9 / latin0) with the international currency sign (¤) instead or insist that char 128 of latin1 is almost always meant as €, so just ignore the standard in these cases and use a new font. This would only fail in older printers and who is still printing stuff these days? Nobody right? Using real utf-8 is just too complex... All these emojis are nuts
- richardwhiuk 2y agoEUR is the common answer.