I wish to create a validator for full names for one of my forms.
Unfortunately I am not sure the best way to go on about is, as it is not as trivial as:
if not char in string.letters + " .'":
raise ValidationError("...")
Thought a regex would work, but \w, [:alpha:], [a-zA-Z] don’t really capture special characters.
Name examples:
-
Tiësto
-
Marie Josèphe
-
Marie Françoise
-
José de Ribas
Any ideas?
I personally wouldn’t bother about validating names, I guess there are so many possiblities it is very hard to maintain. If you could come up with a regular expression, I think it would be so generic it wouldn’t be effective. The only thing I can think of as valuable is excluding things like
@ # $ % ^.Just make sure you are escaping characters, if someone’s name is Fooalert(‘lala’), that’s fine, but make sure it’s not parsed.