Rails validating full_name

前端 未结 3 1466
予麋鹿
予麋鹿 2021-02-03 11:54

Hey... how would you validate a full_name field (name surname).

3条回答
  •  无人共我
    2021-02-03 12:45

    Any validation you perform here is likely to break down unless it is extremely general. For instance, enforcing a minimum length of 3 is probably about as reasonable as you can get without getting into the specifics of what is entered.

    When you have names like "O'Malley" with an apostrophe, "Smith-Johnson" with a dash, "Andrés" with accented characters or extremely short names such as "Vo Ly" with virtually no characters at all, how do you validate without excluding legitimate cases? It's not easy.

提交回复
热议问题