B
B
BonBon Slick2018-02-22 09:22:48
symfony
BonBon Slick, 2018-02-22 09:22:48

Validation for uniqueness?

https://symfony.com/doc/current/reference/constrai...
Doesn't fit, because it needs to be written in the entity.
And it is necessary to validate the data even before the entity is.

$constraint = new Assert(
                [
                    'email' => [
                        new UniqueEntity(
                            [
                                'fields'      => 'email',
                                'errorPath'   => 'email',
                                'entityClass' => User::class,
                                //'em'  => 'some service id',
                                //'repositoryMethod'  => 'findBy',
                                'message'     => 'Not unique email'
                            ]
                        ),

Apparently you need to write your own validator, right?
https://symfony.com/doc/current/validation/custom_...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GTRxShock, 2018-02-22
@GTRxShock

Yes, and by the way, it's quite convenient.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question