自定义验证规则
class WhitelistedEmailDomain implements Rule {
public function passes($attribute, $value) {
return in_array(str_after($value, '@'), ['tighten.co']);
}
public function message() {
return 'The :attribute field is not from a whitelisted email provider.';
}
}$request->validate([
'email' => new WhitelistedEmailDomain,
])Last updated