Le 05/05/2011 23:07, dbenjamin a écrit :
Hi,

I try to use a custom validator, but i didn't found a way :)

First, i use xml for validation and I'm not sure how to add properly a namespace in the config file.

I naively tried to do the same as for annotations or yml drivers:

validation:
    enabled: true
    annotations:
        namespaces:
            AnoMiscBundle: Ano\Bundle\MiscBundle\Validator\Constraints

An then in my validation.xml file :

<property name="username">
<constraint name="AnoMiscBundle:NotExist">
<option name="message">username.NotExist</option>
</constraint>
</property>

But it doesn't recognize the AnoMiscBundle namespace.

<constraint name="Ano\Bundle\MiscBundle\Validator\Constraints\NotExist">

doesn't work either.

What is the proper way ?


Bonus questions :

Since the bundle is a third party bundle, i don't want to force the user to explicitly add a namespace under validation in the config file. Is there a way to add dynamically the namespace when the bundle extension is loaded ? More generally, is there a way to override only some validation rules coming from a bundle or do we need to override the whole validation rules ?


Thanks :-)
As shown by your previous config, the namespace is about annotations. When using XML, just use the FQCN. There is no need to put anything special in the config. See https://github.com/FriendsOfSymfony/UserBundle/blob/master/Resources/config/validation.xml for an example (the custom constraint is a class constraint here).

--
Christophe | Stof

--
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