Name Validation in Laravel

 

Alphabetic and Spaces

Names often contain spaces (e.g., first and last names). To allow alphabetic characters and spaces:


$request->validate([ 'name' => 'required|regex:/^[a-zA-Z\s]*$/', ]);


Including Dashes and Apostrophes

Some names might include dashes or apostrophes. You can adjust the regular expression to allow these:


$request->validate([ 'name' => 'required|regex:/^[a-zA-Z\s\'\-]*$/', ]);



Comments

Popular posts from this blog

2 Column unique validation in controller in Laravel

Axis Bank BBPS API Integration