app/Rules/StrAlphaUnderscore.php
use Illuminate\Contracts\Validation\Rule; class StrAlphaUnderscore implements Rule{ public function passes($attribute, $value) { return preg_match('/^[\pL\pM\pN_]+$/u', $value) > 0; } public function message() { return 'The :attribute may only contain letters, numbers and underscores.'; }}