CodeIgniter Forums
Adding alpha_spaces_dashes as a native validation rule - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: General (https://forum.codeigniter.com/forumdisplay.php?fid=1)
+--- Forum: Lounge (https://forum.codeigniter.com/forumdisplay.php?fid=3)
+--- Thread: Adding alpha_spaces_dashes as a native validation rule (/showthread.php?tid=66366)



Adding alpha_spaces_dashes as a native validation rule - Cannondale - 10-16-2016

Any thoughts on adding alpha_spaces_dashes as a native validation rule? 
Validating a persons last name is very common. Last names can include dashes and spaces but not numbers.
However, this common native validation rule seems to be omitted from the v3.10 list.


RE: Adding alpha_spaces_dashes as a native validation rule - Narf - 10-16-2016

You've forgotten about another somewhat common character in last names - the apostrophe.
And non-ASCII, non-latin letters.

Also, you think that a name cannot include a digit, but that's not true. It's uncommon that somebody would take advantage of that to the fullest extent, but quite a few countries will allow you to change your name to literally anything. That also includes having just a first name, or having more than 3 parts of a name.

The variations are countless, and it's impossible to fit everything in a single rule.

And also, there is no CodeIgniter version "3.10".


RE: Adding alpha_spaces_dashes as a native validation rule - PaulD - 10-16-2016

There are some good examples given here:
http://stackoverflow.com/questions/2385701/regular-expression-for-first-and-last-name

But personally, I would just not validate it in that way (except for min_length, max_length and required of course).

As long as you are cleaning on output, there should be no problem with XSS.


RE: Adding alpha_spaces_dashes as a native validation rule - Cannondale - 10-16-2016

PaulD, thanks for your thoughts. They were helpful.