You can validate not only class attributes, but methods itself. It means, that 
you can create your own method with custom logic, that will return true/false 
in different cases and you can link Boolean validator to that method's return 
value.

--------------------------------------------------Konstantin Kudryashov 
(everzet)
http://about.me/everzet/bio 
On воскресенье, 13 февраля 2011 г. at 21:48, Dan Leech wrote:
Hello ...
> 
> I am trying to figure out how I can apply validation to a field only
> when another field is set to true,
> 
> basic example:
> 
> class SomeEntity
> {
>  /**
>  * @validation: NotBlank();
>  */
>  protected $foo;
> 
>  /**
>  * When true we want to validate $foo
>  */
>  protected $enable_foo;
> }
> 
> Validation Groups crossed my mind, but these apply to the entire form
> and in practice this needs to work on an arbitary number of fields, so
> actually what I want is something like this:
> 
> class SomeEntity
> {
>  /**
>  * @validation: If( -- enable_foo_is_true --) { @validation:NotBlank() }
>  */
>  protected $foo;
> }
> 
> Im guessing that that is a no, Any ideas?
> 
> -- 
> Dan Leech
> 
> Web Developer
> www.dantleech.com
> 
> -- 
> 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 developers" 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-devs?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 developers" 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-devs?hl=en

Reply via email to