CodeIgniter Forums
Multilanguage validation with German "Umlaute" - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Multilanguage validation with German "Umlaute" (/showthread.php?tid=80934)



Multilanguage validation with German "Umlaute" - sprhld - 01-04-2022

Hello!
Today I was working in more details with the valitaion. I choose the model to add the rules and messages. But while testing, I go always an error, when a German "Umlaut" was part of the text. I don't know how to solve this, I didn't find anything Huh 

Here a short examle of the validation:
PHP Code:
'street_no' => 'required|alpha_numeric_space|min_length[5]'
And the text in this filed is
PHP Code:
Düsseldorfer Straße 
The Ü (and maybe the ß) will throw a error message regarding the alpha_numeric_space rule.
Has anyone an Idea hot to upgrade the validation? Or is there an other solution?
Thank you!


RE: Multilanguage validation with German "Umlaute" - includebeer - 01-04-2022

I think you will need to use the regex_match rule and define a regex expression to include the German characters: https://codeigniter.com/user_guide/libraries/validation.html#available-rules


RE: Multilanguage validation with German "Umlaute" - sprhld - 01-04-2022

That was not as hard as I thougt. I saw regex in the docs, regex but regex is regex... Smile 

So my working solution is now:
PHP Code:
'surename'  => 'required|regex_match[/[a-zA-Z ÄäÖöÜüß]/]|min_length[2]'// instead alpha_space
'street_no' => 'required|regex_match[/[a-zA-Z0-9 ÄäÖöÜüß]/]|min_length[5]'// instead alpha_numeric_space 
Thank you and cheers - or "Prost" as we say Smile


RE: Multilanguage validation with German "Umlaute" - includebeer - 01-04-2022

Yeah regex can be confusing, that's why I always use a regex website to test mine! Cool


RE: Multilanguage validation with German "Umlaute" - sprhld - 01-21-2022

(01-04-2022, 12:49 PM)includebeer Wrote: Yeah regex can be confusing, that's why I always use a regex website to test mine! Cool

First I should learn regex before using a testing-website Smile