Lomkit / laravel-rest-api

Generate Api in seconds
https://laravel-rest-api.lomkit.com/
MIT License
297 stars 18 forks source link

Doble validation on "unique:" validation #79

Closed amendozaaguiar closed 7 months ago

amendozaaguiar commented 7 months ago

Laravel Rest Api Version

^2.3

Laravel Version

^10.10

PHP Version

8.1.24

Database Driver & Version

MySQL 8.0.32

Description

At the time of creating a user and applying the unique rule: users, email, the validation is being performed before creating the record and after the record has been created, which is causing the error 'The mutate.0.attributes.email field has already been registered.'

Steps To Reproduce

Rules of validation

`

public function createRules(\Lomkit\Rest\Http\Requests\RestRequest $request)
{
    return [
        'name' => 'required|string|max:255',
        'email' => 'required|email|max:150|unique:users,email',
    ];
}

`

Mutation:

{
    "mutate": [
        {
            "operation": "create",
            "attributes": {
                "name": "test",
                "email": "1@1.com",
            }
        }
    ]
}

Edit 10/11/2023 21:06:00 :

Debugging, I find that the issue arises in the new Hooks features.

GautierDele commented 7 months ago

Hello @amendozaaguiar thanks for your feedback Effectively there is a bug coming with the new feature, i'm on it, will publish a fix in 2 hours 😄 Have a nice day !