I am working on a feature where, upon completion of a form, we validate that the user has entered a "Full name". My assumption here was that I could use PersonNameComponentsFormatter here and simply check for familyName - if it is nil, they haven't entered a "Full name".
However, it isn't behaving quite like I had assumed. For some, seemingly random, Strings it thinks the String is a familyName. I have reproduced this in a playground. See below
let formatter = PersonNameComponentsFormatter()
formatter.style = .default
let strings = ["test", "name", "tester", "naming", "Stefan", "stefan", "card", "dog",
"animal", "first", "string"]
for string in strings {
print(formatter.personNameComponents(from: string)?.familyName ?? "")
}
The result of which is
test
name
tester
card
first
string
Is there a bug here in the formatter or is my assumption on how to use it incorrect? i.e. should I check for both givenName and familyName, rather than relying on just familyName?