Welcome Guest, Not a member yet? Register   Sign In
Multilanguage validation with German "Umlaute"
#1

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!
Reply
#2

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/libra...able-rules
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

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
Reply
#4

Yeah regex can be confusing, that's why I always use a regex website to test mine! Cool
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#5

(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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB