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.

kip

kip

ex_cldr Core Team

Thanks José. For sure anything I do will be opt in.

I suspect there are certain domains - thinking mostly of governments and legal registries - where the requirements are more strict. For example, the state of NSW in Australia has a formal policy that is quite restrictive. And it must be a very very old system since it says:

The Registry is currently unable to include diacritical marks or accents in any name registered in NSW.

Which suggests even your name wouldn’t be able to be registered!

Nefcairon

Nefcairon

If I understand correctly, Kip is not asking what should be generally normalized/validated (this has been discussed very often), but what is often done, so that his library can provide the means.

Where Next?

Popular in Questions Top

New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

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
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
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 record...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
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
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New

We're in Beta

About us Mission Statement