Name Validation Test Cases: Unicode, Spaces & Punctuation
Name validation test cases for forms: the falsehoods programmers believe about names, as a free CSV and JSON fixture pack with Unicode cases.
By Vincent RuanPublished July 20, 2026Last updated October 1, 20268 min read
Download name validation test cases
16 fixed cases · Version 1 · Updated 2026-09-06. Each row includes the original input, test context, expected action, expected value and reason.
Test policy: full-name-v1 is an example full-name field: trim outer ASCII spaces, normalize to NFC, require 1–100 Unicode code points after normalization, and reject line breaks. Preserve internal spaces, punctuation and script; do not infer first or last name by splitting on spaces. The 100-code-point maximum is a declared application constraint, not a universal limit on people's names. Strings that resemble SQL must be stored as text through parameterized queries. Accepting a value here says nothing about a person's identity.
Preview cases and import instructions
JSON is an array of records. CSV uses the same keys and values. Load CSV through an import dialog with every column set to Text: automatic conversion can change leading zeros, plus signs, dates or strings that resemble formulas. JSON preserves Unicode and escaped control characters for automated tests. Empty expectedValue means rejection; it is not a replacement value to store.
Run the input through your implementation with the documented context, compare the action and expectedValue, then check storage and export round trips. Adjust policy-dependent cases to your product before using them as pass/fail gates. Keep the v1 filename with your test results.
| Case | Input | Expected | Value |
|---|---|---|---|
| name-apostrophe | "O'Brien" | accept | "O'Brien" |
| name-hyphens | "Anne-Marie Smith-Jones" | accept | "Anne-Marie Smith-Jones" |
| name-family-spaces | "Ana De la Cruz" | accept | "Ana De la Cruz" |
| name-one-letter | "O" | accept | "O" |
| name-cjk | "李" | accept | "李" |
Policy background: W3C personal names · Unicode normalization. Sources explain the standards and design tradeoffs; they do not endorse every application choice in this fixture set.

Somewhere right now, a person named O'Brien is being told their own name is invalid. A signup form rejects the apostrophe. A ticketing system stores O'Brien, and a hotel confirmation prints OBRIEN. Names are the rare input that is completely legitimate and structurally hostile at once: full of quote characters, odd lengths and non-ASCII letters. That makes them some of the most valuable strings in a test suite. Download the fixed cases above for repeatable coverage. A random name generator adds variety, but it does not guarantee every edge case.
Why names are the most underrated test data
Patrick McKenzie's classic essay lists forty falsehoods programmers believe about names [kalzumeus]. Among them: everyone has exactly one full name, names fit in one character set, names have one correct spelling, and people have a first and a last name in that order. The W3C's internationalization group reaches the same conclusion from many cultures. Almost every structural assumption a form makes about a name is wrong for some large group [w3c-names].
For QA, that is good news. Each falsehood is a ready-made test case. And unlike most edge cases, these arrive on the first day you launch in a new market. A test plan built on realistic, deliberately awkward names catches the failures before your users do. Our guide to generating realistic test data applies the same idea to other fields.
The edge cases that actually break systems
These eight categories account for most name-related production incidents. The examples illustrate input patterns rather than identify customers. Names can coincide with real people; use each string to test the stated behavior.
Apostrophes and quotes
O'Brien, D'Angelo, N'Diaye. The apostrophe ends a string in SQL, quotes an attribute in HTML, and marks a character in many programming languages. Paste a name into any of them and you get a syntax error on a good day and an injection hole on a bad one. The other failure is over-correction. A rule that rejects apostrophes tells many Irish, Italian and West African surnames that they do not exist.
Hyphens, spaces, and multi-word surnames
Smith-Jones, Van Der Berg, De la Cruz, García Márquez. Code that splits a full name on spaces and calls the last word the surname mangles all of these. It files Van Der Berg under Berg and García Márquez under Márquez. Sorting, deduplication and letter greetings all inherit the error. A surname is one unit that may contain spaces and hyphens. Any code that assumes otherwise needs a test case to prove it.
Very short and very long names
Both ends of the length range are real. The Korean surname romanized as O is a single letter, and 李 is a single character. A rule of "at least 2 characters" rejects both. At the other end, real multi-part surnames pass 35 characters, and full names pass 70. That is long enough to overflow an old VARCHAR(30), cut a character in half at a UTF-8 byte limit, or break a fixed-width layout. Test one character and test forty. What happens should be deliberate in both cases.
Unicode, diacritics, and non-Latin scripts
José, Zoë, Nguyễn, 田中, محمد. Modern databases store all of them. The pipeline around storage is where they break. A connection still set to an old encoding turns accents into garbage characters. Unicode also has two ways to write an accented letter: as one character (NFC) or as a letter plus a combining accent (NFD). Two names that look identical can then fail an equality check.
Unicode's normalization report defines these forms, and the practical rule is simple. Normalize to NFC at every system boundary, then test search and deduplication with both forms [unicode-nfc]. Our German identity generator is a handy source of umlauts and ß in otherwise ordinary data. In a sample of 1,000 German profiles, 83 names had one.
Mononyms and missing name parts
Millions of people, most famously in Indonesia, have exactly one name. There is no family name to put in your required last-name field. So these users type a dot, a dash or the same name twice, and your data fills with junk. The W3C guidance and the GOV.UK name pattern both recommend one full-name field where possible, and an optional family-name field where not [w3c-names] [govuk-names]. Your test suite should include at least one profile with no last name at all.
Family-name-first order
In Chinese, Korean, Japanese and Hungarian convention, the family name comes first: in 李小明, the surname is 李. A form that maps the first word to "first name" swaps given name and surname for well over a billion people. The bug only shows up later, in a greeting that uses a customer's family name, or a legal document with the fields reversed. Test with profiles from our Chinese, Korean and Japanese generators, which write the family name first.
We have to admit something here. When we checked that sentence on 1 October 2026, it was false. Our own generators wrote 李小明 as 小明 李, given name first with a Western space, which is the exact bug this section describes. We fixed the generator the same day, for Hungarian and Vietnamese names too, and a test now holds every family-first locale to its order.
Case sensitivity and internal capitals
McDonald, MacIntyre, van der Berg, DiCaprio. Naive title-casing capitalizes the first letter and lowercases the rest. It turns McDonald into Mcdonald in every CRM export. The internal capital is part of the spelling, and the lowercase "van der" is just as deliberate. The safe behavior is to keep exactly what the user typed. Then prove it survives a round trip through normalization, storage and display.
Whitespace and invisible characters
A trailing space pasted along with a name. A non-breaking space copied from a web page. A zero-width joiner hidden in text from a messaging app. Two records that look identical but differ by an invisible byte defeat deduplication and make login by name fail for no visible reason. The usual recipe is to trim the ends, collapse inner runs of spaces, strip zero-width characters, then compare. It only earns trust when a test feeds it deliberately dirty input.
Little Bobby Tables: injection is a name problem
Did you really name your son Robert'); DROP TABLE Students;--?
The most famous name in software testing belongs to a fictional schoolboy whose mother named him after a SQL injection attack [xkcd-327]. The joke works because a name is untrusted input that looks trustworthy. The lesson is not to scrub names harder. It is that parameterized queries and context-aware output encoding make the string's contents irrelevant. A Bobby Tables string belongs in your fixtures not because users are attackers. It proves in one assertion that no code builds queries by pasting strings together.
| Test name | What it exercises | Typical failure | Fix to verify |
|---|---|---|---|
| O'Brien | Apostrophe in surname | SQL/HTML escaping errors; validator rejects the name | Parameterized queries; allow ' in name fields |
| Anne-Marie Smith-Jones | Hyphens in given and family name | Split-on-hyphen logic; over-strict character rules | Treat each name part as opaque text |
| Van Der Berg | Multi-word surname with particles | Split-on-space maps surname to Berg | Never derive surname by splitting tokens |
| O | One-character surname | Minimum-length validation rejects it | Allow single-character name parts |
| Wolfeschlegelsteinhausenbergerdorff | 35+ character surname | Column truncation; UI overflow | Length budget ≥ 100 chars; test truncation behavior |
| Nguyễn Thị Minh Khai | Diacritics + multi-part name | NFC/NFD mismatch breaks search and dedupe | Normalize to NFC at system boundaries |
| 李小明 | CJK script, family-name-first | Mojibake; given/family fields swapped | UTF-8 end to end; full-name field or explicit order |
| Suharto | Mononym, no family name | Required last-name field blocks signup | Make family name optional |
| Robert'); DROP TABLE Students;-- | SQL metacharacters (Bobby Tables) | String-concatenated queries execute the payload | Parameterized queries everywhere |
How to generate edge-case names for your test suite
A fixed list like the table above is a start. Real coverage needs volume and variety: hundreds of profiles in which the awkward names arrive inside otherwise consistent identities, as they would in production. That is what a locale-aware generator is for. Our country generators produce names with each locale's apostrophes, diacritics and name order, attached to matching addresses and phone numbers. For fixture files, the bulk generator exports up to 100,000 US records as CSV, JSON or SQL inserts. It is US-only, so build other locales from the country pages.
- Mix locales deliberately. Combine Irish names, German umlauts and Chinese name order in one dataset, so every part of the system meets every category. Generate a few hundred Irish profiles: only about 1 in 100 carries an O' surname.
- Export, don't retype. Save the cases you need to a file and commit it with your fixtures, so the same awkward names run on every CI build. The bulk exporter does this for US records, and the downloads above cover the hand-picked cases.
- Cover nearby fields too. A username generator shows what the same person's handle looks like after the awkward characters are stripped. That is a separate normalization worth testing.
- Make it reproducible. Seed your generation so a failing test can rerun on identical data. See why seeding beats random test data.
Validation rules that respect real names
Testing with awkward names usually shows that validation, not storage, is the real offender. The goal is to check structure without policing vocabulary. That is the approach the GOV.UK pattern settled on after user research [govuk-names]:
- Do accept letters from any script, apostrophes, hyphens, spaces, and periods in every name field.
- Do trim surrounding spaces and normalize Unicode before comparing or deduplicating, but store what the user typed.
- Do budget generous lengths (100 characters per field) and define truncation behavior explicitly.
- Don't require a minimum of two characters, a family name, or a Latin-script spelling.
- Don't title-case, uppercase, or otherwise "fix" capitalization the user chose.
- Don't try to scrub names for safety. Parameterize queries and encode output, so the name's contents never matter.
Names as free chaos engineering
Names are free chaos engineering: a handful of fictional strings that together audit your escaping, validation, encoding, length handling and cultural assumptions. Put the starter suite above into your fixtures. Use bulk US test records for volume and the country tools for other locales. When a fixture needs one sex, use the fake female name generator or its male counterpart. Then treat every name bug you find as a falsehood you can delete from your code for good.
References & sources
- Falsehoods Programmers Believe About Names — Kalzumeus (Patrick McKenzie)
- Personal names around the world — W3C Internationalization
- Names — GOV.UK Design System pattern — GOV.UK Design System
- UAX #15: Unicode Normalization Forms — Unicode Consortium
- Exploits of a Mom (Little Bobby Tables) — xkcd
Frequently asked questions
Why do forms reject apostrophes in names, and should they?
The apostrophe in O'Brien ends a string in SQL and quotes an attribute in HTML and JavaScript. Code that pastes a name into a query or template, instead of using parameterized queries and proper encoding, throws a syntax error or corrupts the output. In the worst case it runs whatever follows the quote. Validators that simply reject apostrophes swap a crash for locking out millions of real people.
Should a registration form require a last name?
Only if your system cannot work without one. Mononyms, a single name with no family name, are standard in Indonesia, Myanmar, parts of India and elsewhere. A required last-name field misrepresents these users. The W3C and the GOV.UK design system both recommend a single full-name field where possible. If names must be split, make the family name optional.
How long can a person's name be, and how long should a form allow?
Test both extremes. One-character surnames are real: the Korean surname romanized as O, or the Chinese surname 李. At the long end, real hyphenated and multi-part surnames pass 35 characters. A safe habit is to allow at least 100 characters per name field. Then test what your UI, database column and exports do at the limit. Truncation should be a decision, not an accident.
Are non-Latin names safe in modern databases?
Storage is rarely the problem now. Any UTF-8 column stores 田中 or محمد fine. The failures happen around storage. A connection set to an old encoding garbles the text. Search and deduplication miss matches because José can be encoded two ways, called NFC and NFD. Case-insensitive comparison also differs between collations. Test accented, CJK and right-to-left names end to end, not just at the INSERT.
Which edge-case names should be in every QA test suite?
A useful starter set: O'Brien for the apostrophe, Anne-Marie Smith-Jones for hyphens, a multi-word surname like Van Der Berg, a one-character surname and a 40-character one. Add an accented name like Nguyễn, a CJK name like 李小明, a mononym, a name with a leading or trailing space, and one Bobby Tables string of SQL characters. Together they test escaping, validation, length limits, Unicode and name order.
Should a form split the full name into first and last name?
Only if a downstream system needs the parts. Splitting a typed full name on spaces files Van Der Berg under Berg and García Márquez under Márquez. It also reverses given and family names for Chinese, Korean, Japanese and Hungarian users, whose family name comes first. The W3C and GOV.UK both recommend one full-name field where possible. If you must split, ask for the parts in separate fields, make the family name optional, and never derive one field from the other.
Update history
- Measured how often our generators produce each awkward case, fixed our East Asian generators to write the family name first, and rewrote the prose in shorter sentences.
- Added the 16 downloadable test cases in CSV and JSON, retitled the post for name validation test cases, and added the question-style FAQs.
- Added links to the female and male name generators for fixtures that need one sex.
- Replaced an invented author persona in the byline with the site's real author.
- Published, with eight categories of names that break software and a starter test suite.
More on names and name data
- Why Random Name Generators Repeat: The Birthday Paradox
- Who Is John Doe? Meaning and History of the Placeholder Name
- Is Using a Fake Name Generator Legal? Lawful Uses vs Fraud
- Most Common Last Names in the US: Top 100 (2020 Census)
- Most Common French Last Names: Top 100 (INSEE Data)
- randomuser.me Alternative: Photos & Address Fixtures