How to validate person names? - Python/Django

前端 未结 4 369
清歌不尽
清歌不尽 2021-01-21 13:28

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:<

相关标签:
4条回答
  • 2021-01-21 14:03

    Depending on your version of python it might be re.UNICODE you are looking for?

    http://docs.python.org/library/re.html#re.UNICODE

    0 讨论(0)
  • 2021-01-21 14:05

    Don't.

    Please, read this carefully: Falsehoods Programmers Believe About Names.

    0 讨论(0)
  • 2021-01-21 14:15

    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.

    0 讨论(0)
  • 2021-01-21 14:17

    I don't think it is a good idea.

    What kind of names would you like to exclude? There is no international list of allowed characters for names and there is not much reason to disallow specific characters.

    0 讨论(0)
提交回复
热议问题