Hi Bernhard,

I updated my config.yml and added:

app.config:
     validation:
           enabled: true
           annotations:
                namespaces:
                     mybundle:
 Application\MyBundle\Component\Validator\Constraints\

And now in my Entity:

/**
  * @orm:Column(type="string", length="16")
  * @validation:NotBlank()
  * @mybundle:IpAddress()
  */

But I couldn't get it to work. I tried if NotBlank is still working but it
doesn't work now. Did I miss something?

I updated the pastebin codes correcting some typos just in case:

Constraint: http://pastebin.com/gGJKpc3Z
Constraint Validator: http://pastebin.com/U685DjV5


Checked if the "isValid" method is getting called on my custom constraint
validator, but it's not.



Thanks in advance for your help!


On Tue, Nov 23, 2010 at 12:28 PM, Bernhard Schussek <[email protected]>wrote:

> Hi Gustavo,
>
> Sorry, the documentation is lacking in that part. You need to register
> your constraint namespace to use it with the validation driver. Add
> this to your config.yml
>
>    validation:
>        enabled: true
>        annotations:
>            namespaces:
>                myvalidation:
> Application\MyBundle\Component\Validator\Constraints\
>
> Then you can refer to the constraint using @myvalidation:IpAddress.
>
> Bernhard
>
> --
> Software Architect & Engineer
> Blog: http://webmozarts.com
> Twitter: http://twitter.com/webmozart
>
>
>
> 2010/11/23 Gustavo Adrian <[email protected]>:
> > Hi everyone,
> > I've created a custom validator for IP Addresses but is not getting
> called.
> > What I did is simply copy the existent Url validator files (Url and
> > UrlValidator), changed the pattern accordingly and removing some stuff
> > (protocols, etc). Then in my Entity via annotations:
> >
> > /**
> >   * @orm:Column(type="string", length="16")
> >   * @validation:NotBlank()
> >   * @validation:IpAddress()
> >   */
> > protected $primaryDns;
> > NotBlank constraint is working, but my custom validator doesn't. I've put
> my
> > files in
> >
> > Application/MyBundle/Component/Validator/Constraints/IpAddress.php
> >
> Application/MyBundle/Component/Validator/Constraints/IpAddressValidator.php
> >
> >
> > Am I missing some step? I've followed the docs
> > from
> http://docs.symfony-reloaded.org/master/guides/validator/constraints.html
> > My Constraint:  http://pastebin.com/zcf8YQ3C
> > My Constraint Validator:  http://pastebin.com/uN9nqA6A
> >
> > Thanks in advance.
> >
> > --
> > 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]<symfony-users%[email protected]>
> > For more options, visit this group at
> > http://groups.google.com/group/symfony-users?hl=en
> >
>
> --
> 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]<symfony-users%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>

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

Reply via email to