Bonfire icon indicating copy to clipboard operation
Bonfire copied to clipboard

Validation rule for names, UTF8 compatible

Open xcript opened this issue 11 years ago • 7 comments

Please add an UTF8 compatible validation rule for names. This should work:

public function name($str)
{
    return ( ! preg_match("/^\p{L}[\p{L} .-]+$/u", $str)) ? FALSE : TRUE;
}

xcript avatar Sep 04 '13 13:09 xcript

It would probably be better to add this as more of another validation rule checkbox than just an overall check.

ragingdave avatar Sep 04 '13 22:09 ragingdave

It's a function, which can be used as a validation rule. Maybe it could be a new checkbox too.

xcript avatar Sep 10 '13 17:09 xcript

This seems the wrong place to check UTF8 compatibility! I don't understand the code, so perhaps your definition of UTF8 compatibility is different from mine.

However if the form is submitted with a UTF8 charset, and the form data is not valid UTF8 encoded, that's a software bug. We can't blame the poor user for it! We should give a technical error targeted at troubleshooters, not one written for users. (Why should users know what UTF8 means???).

Maybe you know there are bad browsers that we're not going to work around. Is that it? In that case we still shouldn't complain unintelligibly about UTF8 to our users! We could tell users that certain browsers are broken and they should upgrade their browser. UTF8: it's the law.

sourcejedi avatar Sep 11 '13 18:09 sourcejedi

I don't know what you are talking about. I'm talking about Bonfire, not any application based on it.

Try to validate the name "Subašić" with the validation rule "alpha" and you will know what I mean.

xcript avatar Sep 11 '13 19:09 xcript

Apologies @script. I missed the focus on people's names. Having understood the question I respectfully suggest not doing this.

How important is it to deny people with names containing

If there are worries about specific characters in name fields - newlines or various other ASCII control characters, the deprecated unicode formatting characters - it seems better to blacklist the ones we don't want. (I wouldn't object to banning runs of multiple space characters either).

sourcejedi avatar Sep 11 '13 20:09 sourcejedi

No problem for me, but we have to congretize the context we are talking about. The validation rule should not be used for usernames or any data uncontolled users could enter. My context is a validation of data entered in a controlled environment. The developer is responsible for the use of it!

Thanks for the links. They are very interesting!

In my case I save lists of names of soccer players for a game script. This is a controlled environment, because only a few known users enters the data.

Again: I'm talking about a validation rule developers could use for their application. Any developer should be aware of the risks. You won't give back your driver's license, because you possibly could driving through a red traffic light. This rule is missing in Bonfire. If the Bonfire team decides not to integrate it, then this issue maybe helps some others to get it, if they need it.

xcript avatar Sep 11 '13 21:09 xcript

It looks like CodeIgniter has a fix in place for alpha() in v3, but it hasn't been back-ported to v2.x (I'm also not 100% sure it works, since it's dependent on using setlocale()). We probably should look at updating alpha_extra() in libraries/MY_Form_validation.php to handle international characters as well.

mwhitneysdsu avatar Sep 16 '13 14:09 mwhitneysdsu