Closed
Description
<?php
namespace Application\MyBundle\Entity
use Symfony\Component\Validator\Constraints as Assert;
class User
{
public function getRoles()
{
throw new \Exception("getRoles should not be called");
}
/**
* @Assert\True
*/
public function isRoles()
{
return true;
}
}
<?php
//some controller-action
$user = new User;
$list = $this->get('validator')->validate($user);
You may expect that entity is valid, because method with Assert\True always returns true, but instead this exception will be thrown - Validator\Mapping\GetterMetadata firstly checks 'get%Prop' than 'is%Prop' methods.
Looks like main problem is that all constraints basically binded to properties, even constraints on getters. This also doesn't described properly in docs, what causes such funny issues as described above.