laravel validation rule for only letters

Your regex fails I think, I tried it on Regexr and couldn't get it to function, try this:

'name' => 'required|regex:/^[a-zA-Z]+$/u|max:255|unique:users,name,'.$user->id,

Let me know how you get on.

Here's the regex only: ^[a-zA-Z]+$


According to laravel documentation you can use :

  • alpha for entirely alphabetic characters
  • alpha_dash for alpha-numeric characters, as well as dashes and underscores and finally
  • alpha_num for entirely alpha-numeric characters.

Tags:

Php

Regex

Laravel