Answer the question
In order to leave comments, you need to log in
Why is the symfony validator not working?
There is an essence
<?php
namespace Model;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="Repository\UserModel")
* @ORM\Table(name="`user`")
* @ORM\HasLifecycleCallbacks()
*/
class UserModel extends \Core\ModelCore
{
/**
* @ORM\Id
* @ORM\Column(type="integer", name="user_id")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string")
* @Assert\Email()
*/
protected $email;
/**
* @ORM\Column(type="string", length=100)
* @Assert\Length(
* min = 2,
* max = 100
* )
* @Assert\NotBlank()
*/
protected $fname;
//.....
$user = new UserModel;
//Заполняю данные
$validator = Validation::createValidator();
$errors = $validator->validate($user);
ConstraintViolationList {#103
-violations: []
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question