Hi Bernhard: > I'm not sure I understand the example. Can you put @NotBlank > constraints on all fields, and additionally @IpAddress constraints on > the first three?
No, the problem is that, if the user fills the fourth field, I need it to be a valid IP, so I need the same IpAddress Validator on the four fields. But, if the user does not fill the fourth field, it's ok because its optional. The problem is if I just use @IpAddress on that field and I don't enter a value, it will complain because is not a valid IP either. field1: @NotBlank @IpAddress field2: @NotBlank @IpAddress field3: @NotBlank @IpAddress field4: @IpAddress -> if I don't fill this field, it will complain because an empty string it's not a valid IP either. > There currently is no way to configure the expected type of an option. I saw that the "Choice" validator has an option called "multiple" and it accepts a boolean value. But, as you said, it doesn't support boolean values. Looking at the code of the validator I saw that it treats it like a boolean. Then, it would always return true if you enter a string like "false" or "true". Is this ok or it's handled different on a file that I didn't saw yet? Thanks in advance! On Thu, Nov 25, 2010 at 2:50 PM, Bernhard Schussek <[email protected]>wrote: > 2010/11/24 Gustavo Adrian <[email protected]>: > > Hi everyone, > > I've recently created a custom validator to validate IP. I have four > fields > > that need a mandatory IP, and one field in that the IP is optional. > > I'm not sure I understand the example. Can you put @NotBlank > constraints on all fields, and additionally @IpAddress constraints on > the first three? > > > The thing is that, on the "isValid" method, checking for the "required" > > property of the constraint I've noticed that the value was indeed a > string, > > and not a boolean. > > There currently is no way to configure the expected type of an option. > > 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]<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
