kip

kip

ex_cldr Core Team

Person name formatting / normalisation - feedback request

TLDR; Seeking feedback on what, if any, normalisations and validations should be provided when accepting input that represents a person’s name.

Context

When you accept input for the name of a person, what validation or normalisation do you normally do?. CLDR 48 will be out very soon and with it new releases of many of the ex_cldr libraries.

One of these is ex_cldr_person_names which supports formatting names in a locale-sensitive way. I have an opportunity to provide some validations or normalisations as optional capabilities.

Person Name Validation - current practise

When implementations allow entry of person names, they can be too strict; there are instances where people can’t enter their real names, such as O’Brian, Stéphanie, Wałęsa, Þjóðólfr.

When you accept input for a person’s name do you:

  • Do nothing - as long as its UTF-8 it’s ok?
  • Restrict to a single script? Maybe thats too lenient - even the Latin script has over 1_400 characters in it
  • Do you allow emoji characters, like the name B​:o_button_blood_type:b?
  • What about the always fun Zalgo text?

Possible normalisations

  • Transform to Unicode NFC format
  • Replacement of arbitrary sequences of whitespace characters by a single space .
    • \p{whitespace}{2,∞} → U+0020
  • Replacement of U+2010 HYPHEN and U+2011 NON-BREAKING HYPHEN
    • [‐‑] → -

Additional possible constraints

  • Too many identical grapheme clusters in a sequence
    • (Tóóóóóm)
  • Too many non-letters in a row
    • (Jean—Luc Jr.., MD)
  • Too many combining marks in a row
    • Faruq̣̣̈̈

Not in scope

Removing profane words or otherwise accepting or rejecting words according to some dictionary.

Most Liked

josevalim

josevalim

Creator of Elixir

I usually just leave it free form. Because if someone wants to have fun with your name input, they will be able to, even with only ASCII characters. And once you allow a bit of Unicode, which you need to anyway, it already opens up too many possibilities.

mudasobwa

mudasobwa

Creator of Cure

In my humble opinion, the general purpose library should not try to satisfy needs of any weird restrictive software behind the business/govt websites/apps. If they don’t allow anything but ASCII-7, they would be perfectly able to filter it out on their own.

Where Next?

Popular in Questions Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44167 214
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New

We're in Beta

About us Mission Statement