Answers for "laravel custom validation check if valid url"

PHP
0

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",
Posted by: Guest on April-15-2021

Code answers related to "laravel custom validation check if valid url"

Browse Popular Code Answers by Language