Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make http/https optional in laravel validation

Tags:

laravel-4

When I use laravel url validation rules like:-

array(
      'name' => 'required|min:3',
      'url' => 'required|url'
)

It rejects any url that does not have http:// or https://. However I would like to make it optional.

like image 387
Dipendra Gurung Avatar asked May 20 '26 00:05

Dipendra Gurung


1 Answers

You can just ignore the url rule. Or you need to prefix your input.

Another way is to set an custom rule.

like image 67
Robin Avatar answered May 23 '26 00:05

Robin