laravel custom validation check if valid url code example
Example: laravel custom validation check if valid url
I have created a custom 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 now:
"url" => "required|german_url,
Also don't forget to add the rule to your validation.php file
"german_url" => ":attribute is not a valid URL",