Answers for "validation laravel url"

PHP
8

if any error in blade laravel

@if ($errors->any())
     @foreach ($errors->all() as $error)
         <div>{{$error}}</div>
     @endforeach
 @endif
Posted by: Guest on November-01-2020
1

laravel unique validation

unique:table,column,except,idColumn

############## Example : ################

############### For Updating  
//rules
'email' => 'unique:users,email_address,' . $userId,

############### For Creating 
//rules
'email' => 'unique:users,email_address',
Posted by: Guest on October-26-2020
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

Browse Popular Code Answers by Language