laravel custom validation check if valid url

Solutions on MaxInterview for laravel custom validation check if valid url by the best coders in the world

showing results for - "laravel custom validation check if valid url"
Mariangel
06 Nov 2019
1I have created a custom Validator like:
2
3Validator::extend('german_url', function($attribute, $value, $parameters)  {
4  $url = str_replace(["ä","ö","ü"], ["ae", "oe", "ue"], $value);
5  return filter_var($url, FILTER_VALIDATE_URL);
6});
7
8My rules contain now:
9"url" => "required|german_url,
10
11Also don't forget to add the rule to your validation.php file
12"german_url" => ":attribute is not a valid URL",