Stop, the error is found... I defined the wrong namespace for my constraint class!
Replacing namespace Symfony\Component\Validator\Constraints; by namespace Application\RsBundle\Component\Validator\Constraints; solved the problem. Sorry for bothering you... and have a nice day, Christian On Jan 20, 4:33 pm, cestcri <[email protected]> wrote: > Hi Bernhard, > > thanks for your quick reply. Here is what I have: > > The validation setup in the entity class > > /** > * @var text $locationName > * @myvalidation:Location(property="locationName", > message="Geocoding of location failed!") > */ > private $locationName; > > The setup in config.yml > > app.config: > validation: > enabled: true > annotations: > namespaces: > myvalidation: Application\RsBundle\Component > \Validator\Constraints\ > > The constraint class: > > <?php > > namespace Symfony\Component\Validator\Constraints; > > class Location extends \Symfony\Component\Validator\Constraint > { > public $message = 'The location is not valid.'; > > } > > The validator: > > <?php > > namespace Application\RsBundle\Component\Validator\Constraints; > > use Symfony\Component\Validator\Constraint; > use Symfony\Component\Validator\ConstraintValidator; > > class LocationValidator extends ConstraintValidator > { > public function isValid($object, Constraint $constraint) > { > throw new \RuntimeException('This is it.'); > } > > } > > isValid() is never called, i.e. the exception is not thrown. > > Happy to get some advice :) > > Thanks in advance, > Christian > > On Jan 20, 2:56 pm, Bernhard Schussek <[email protected]> wrote: > > > 2010/11/24 Ases <[email protected]>: > > > > From annotations works fine, but how I would have to call it from > > > validation.yml? > > > > #Application/MyBundle/Resources/config/validation.yml > > > Application\MyBundle\Entity\Anything: > > > getters: > > > address: > > > - NotBlank: ~ > > > - IpAddress: ~ > > > BTW, you can now define namespace prefixes in YAML and XML files as well > > > # Application/MyBundle/Resources/config/validation.yml > > namespaces: > > mybundle: Application\MyBundle\Component\Validator\Constraints\ > > > Application\MyBundle\Entity\Anything: > > getters: > > address: > > - NotBlank: ~ > > - "mybundle:IpAddress": ~ > > > Don't forget the quotes. > > > 2011/1/20 cestcri <[email protected]>: > > > > If anybody has the same troubles or approaches, please give a shout. > > > Somehow this custom validation topic has to be mastered... > > > Can you show some code? > > > Bernhard > > -- > > Software Architect & Engineer > > Blog:http://webmozarts.com > > Twitter:http://twitter.com/webmozart -- 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
