Why not just use Spark::validateUsersWith() and Spark::createUsersWith()?
https://spark.laravel.com/docs/7.0/adding-registration-fields
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
In Spark, I'm trying to swap out the default registration Validator for a custom one.
(Why? I need to do some fancy checks on the email address that go beyond the scope of simple validation rules.)
In Laravel\Spark\Interactions\Auth\CreateUser, I found a baseValidator method that defines the Validator for registration. So then I tried setting up a Spark::swap in SparkServiceProvider:
Spark::swap(
'CreateUser@baseValidator',
function($request){
$validator = Validator::make(
$request->all(),
[
'first_name' => 'required|max:255',
'last_name' => 'required|max:255',
'email' => 'required|email|max:255|unique:user',
'password' => 'required|confirmed|min:6',
'country' => 'required',
'terms' => 'required|accepted',
]
);
if ($validator->fails()) {
// I'll insert code to handle special email validation cases here.
return back()
->withErrors($validator)
->withInput();
}
}
);
But it appears that this Spark::swap call is being completely ignored. When I attempt to register, the default validation rules are run instead of the ones defined above.
Does anyone know what I'm doing wrong? Thanks in advance!
Why not just use Spark::validateUsersWith() and Spark::createUsersWith()?
https://spark.laravel.com/docs/7.0/adding-registration-fields
Please or to participate in this conversation.