13 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?
- barryrandall 2y agoAnything is possible with enough qualifiers and caveats.
- 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:
- dvfjsdhgfv 2y agoYou seem to have forgotten quite a few, like
- Macha 2y agoHonestly I wish we could just abolish first and last name fields and replace them with a single free text name field since there's so many edge cases where first and last is an oversimplification that leads to errors. Unfortunately we have to interact with external systems that themselves insist on first and last name fields, and pushing it to the user to decide which is part of what name is wrong less often than string.split, so we're forced to become part of the problem.
- caseyohara 2y agoI did this in the product where I work. We operate globally so having separate first and last name fields was making less sense. So I merged them into a singular full name field. The first and only people to complain about that change were our product marketing team, because now they couldn’t “personalize” emails like `Hi <firstname>,`. I had the hardest time convincing them that while the concept of first and last names are common in the west, it is not a universal concept. So as a compromise, we added a “Preferred Name” field where users can enter their first name or whatever name they prefer to be called. Still better than separate first and last name fields.
- poizan42 2y agoSee point 40 and 32-36 on Falsehoods programmers believe about names[1] [1] https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-...
- from-nibly 2y agoI know that this is trying to be helpful but the snark in this list detracts from the problem.
- i80and 2y agoWhether it's healthy or not, programmers tend to love snark, and that snark has kept this list circulating and hopefully educating for a long time to this very day
- armada651 2y agoYes, it is essential when you want to avoid doing business with customers who have invalid names.
- 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.
- majkinetor 2y agoSure it is. Context matters. For example, in clone wars.
- 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.
- eyelidlessness 2y agoThat sounds like a reasonable assumption, but probably not strictly correct.
- 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")
- 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.
- 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.
- bjackman 2y agoI still don't see how any system in the real world can safely assume its users only have names from that list. Even if you try to imagine a system for a hospital to register newly born babies... What happens if a pregnant tourist is visiting?
- perching_aix 2y agoWith plenty of attitude of course :) I've only ever interacted with freeform textfields when inputting my name, so most regular systems clearly don't dare to attempt this. But if somebody was dead set on only serving local customers or having only local personnel, I can definitely imagine someone being brave(?) enough.
- Y_Y 2y agoFor example in Iceland you don't have to name the baby immediately, and the registration times are different for foreign parents.https://www.skra.is/english/people/registration-of-children/children-born-in-iceland/ https://www.skra.is/english/people/registration-of-children/... Of course then you may fall foul of classic falsehood 40: People have names.
- rrr_oh_man 2y agoFor today's lucky 10,000: Falsehoods programmers believe about names (https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-...)
- 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...
- account42 2y agoPerhaps you shouldn't be speaking for Germans then? Personally, I'd rather not have localization forces on me. Looking at you, Google.
- MrJohz 2y agoI don't think localisation should be forced on anyone, but we had enough people using our software who couldn't speak English that getting it right would have made a lot of people's lives easier. At one place I worked, they even added Cantonese text to a help page to let Cantonese users know how to get support - but all the text on the buttons and links to get to that point was in English! As developers, we need to build software for our users, and not for ourselves. That means proper localisation, and it means giving users the option of choosing their own language and settings.
- 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