Skip to content

Commit

Permalink
add new unique email validator
Browse files Browse the repository at this point in the history
  • Loading branch information
esizer committed Sep 28, 2022
1 parent 51ffc39 commit e4e11de
Show file tree
Hide file tree
Showing 3 changed files with 1,339 additions and 1,015 deletions.
38 changes: 38 additions & 0 deletions api/app/GraphQL/Validators/UpdateUserInputValidator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\GraphQL\Validators;

use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Rule;
use Nuwave\Lighthouse\Validation\Validator;

final class UpdateUserInputValidator extends Validator
{
/**
* Return the validation rules.
*
* @return array<string, array<mixed>>
*/
public function rules(): array
{

Log::debug($this->args->toArray());

return [
'email' => [
'sometimes',
Rule::unique('users', 'email')->ignore($this->arg('id'), 'id'),
]
];
}

/**
* Return the validation messages
*/
public function messages(): array
{
return [
'email.unique' => 'This email address is already in use',
];
}
}
Loading

0 comments on commit e4e11de

Please sign in to comment.