I thought of that but it worked before the recent update to annotations. 
@Assert\True works with the True constraint that comes with Symfony2. It 
looks like Doctrine is trying to parse all annotations regardless of whether 
they're relevant to Doctrine. Unless @Assert\True is built into Doctrine, 
I'm having trouble figuring out why that works but @Birthday\True doesn't. 
I'm also using the EWZ RecaptchaBundle and the custom validator that it uses 
no longer works as well. That also uses a custom True constraint similar to 
the one I posted above.

I'm going by the example found here:

http://symfony.com/doc/2.0/reference/constraints/True.html (click the 
Annotations tab)

The only difference is that I'm using a custom validator class and a custom 
constraint. I've looked at the way the constraint and validator classes work 
in the framework and I'm not seeing anything wrong with what I'm doing.

Here's my service definition:

<?xml version="1.0" encoding="UTF-8"?>

<container xmlns="http://symfony.com/schema/dic/services";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://symfony.com/schema/dic/services 
http://symfony.com/schema/dic/services/services-1.0.xsd";>

    <parameters>
        <parameter 
key="birthday.validator.true.class">CFP\Bundle\AccountBundle\Validator\Constraints\Birthday\TrueValidator</parameter>
    </parameters>

    <services>
        <service id="birthday.validator.true" 
class="%birthday.validator.true.class%">
            <argument type="service" id="service_container" />
            <tag name="validator.constraint_validator" alias="birthday.true" 
/>
        </service>
    </services>
</container>

And my True class:

namespace CFP\Bundle\AccountBundle\Validator\Constraints\Birthday;

use Symfony\Component\Validator\Constraint;

class True extends Constraint
{
    public $message = 'You must be at least %min_age% years old to 
register';

    /**
     * {@inheritdoc}
     */
    public function getTargets()
    {
        return Constraint::PROPERTY_CONSTRAINT;
    }

    /**
     * {@inheritdoc}
     */
    public function validatedBy()
    {
        return 'birthday.true';
    }
}

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to