Laravel URL validation not working

There could be any reason for laravel URL validation not working in your case. Here we provides some validation rules which helps you to validate URL.

Answers 2
  • URL validation in laravel

    public function store(Request $request){
        $request->validate([
            'website' => 'required|url',
        ]);
    }
    
    0

    You can validate a website URL in laravel using url rule in validate() method.

  • Laravel URL validation with https using regex

    //Inside controller's method
    $regex = '/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/';
    $request->validate([
        'url' => 'required|regex:'.$regex,
    ]);
    
    0
  • Back to code snippet queries related laravel