N
N
NubasLol2018-08-29 16:43:55
symfony
NubasLol, 2018-08-29 16:43:55

UniqueEntity symfony how to apply in Controller?

$constraint = new Assert\Collection([
            'username' => new Assert\NotBlank(['message' => 'Укажите ФИО']),
            'email' => new Assert\NotBlank(['message' => 'Укажите Email']),
            'phone' => new Assert\NotBlank(['message' => 'Укажите телефон']),
            'password' => new Assert\NotBlank(['message' => 'Введите пароль']),
            'check' => new Assert\NotBlank(['message' => 'Вы должны согласиться на обработку данных']),
        ]);

        $violations = $validator->validate($data, $constraint);

Now this code works beautifully, but the email field still needs to be made unique and also validated, how can I do that?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artemy Lapko, 2018-08-29
@artemylapko

In essence, specify unique=true
And validate - a simple selection from the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question