Laurvel url validation umlauts
Laravel uses filter_var() with the FILTER_VALIADTE_URL option, which does not allow umlauts. You can write a special validator or use the regex validation rule in combination with a regular expression. I'm sure you will find here here
"url" => "required|regex:".$regex Or it is better to specify the rules as an array to avoid problems with special characters:
"url" => array("required", "regex:".$regex) Or, as @michael points out, just replace umlauts before checking. Just make sure you keep the real sweat:
$input = Input::all(); $validationInput = $input; $validationInput['url'] = str_replace(['ä','ö','ü'], ['ae','oe','ue'], $validationInput['url']); $validator = Validator::make( $validationInput, $rules ); if($validator->passes()){ Model::create($input); // don't use the manipulated $validationInput! } Thanks to @michael and @lukasgeiter for showing me the right path. I decided to post my solution if anyone has the same problem.
I created a special validator like:
Validator::extend('german_url', function($attribute, $value, $parameters) { $url = str_replace(["ä","ö","ü"], ["ae", "oe", "ue"], $value); return filter_var($url, FILTER_VALIDATE_URL); }); My rules contain:
"url" => "required|german_url, Also do not forget to add the rule to the validation.php file
"german_url" => ":attribute is not a valid URL",