On Apr 2, 10:32 am, Jonathan Lundell wrote:
> I think I've seen an answer to this one, but I can't find it.
>
> I've got a form with two Field's, both IS_IPV4(). The validation I'm after is
> that one or both must be present; the only invalid case is both of them null.
>
sort of a situation
db.table.field1.requires=IS_NULL_OR(IS_IPV4())
db.table.field2.requires=IS_NULL_OR(IS_IPV4()) if request.vars.field1
else IS_IPV4()
On Apr 2, 10:32 am, Jonathan Lundell wrote:
> I think I've seen an answer to this one, but I can't find it.
>
> I've got a form with two Field's, both IS_IPV4(). The
On Apr 2, 7:14 pm, mdipierro wrote:
> db.table.field1.requires=IS_NULL_OR(IS_IPV4())
> db.table.field2.requires=IS_NULL_OR(IS_IPV4()) if request.vars.field1
> else IS_IPV4()
Thank you for this, Massimo - this is a nice, compact idiom for using
existing validators; I hadn't considered (don't know
Yes. No one solution is obviously better. It is good to have some
options.
Massimo
On Apr 2, 8:45 pm, Yarko Tymciurak
wrote:
> On Apr 2, 7:14 pm, mdipierro wrote:
>
> > db.table.field1.requires=IS_NULL_OR(IS_IPV4())
> > db.table.field2.requires=IS_NULL_OR(IS_IPV4()) if request.vars.field1
> > e
You can also do
db.table.field1.requires=IS_NULL_OR(IS_IPV4())
db.table.field2.requires=IS_NULL_OR(IS_IPV4())
def at_least_one(form):
if not form.vars.field1 and not form.vars.field2:
form.errors.field2='cannot be empty if field1 is empty'
form.errors.field1='cannot be empty
On Apr 2, 11:06 pm, mdipierro wrote:
> You can also do
>
> db.table.field1.requires=IS_NULL_OR(IS_IPV4())
> db.table.field2.requires=IS_NULL_OR(IS_IPV4())
>
> def at_least_one(form):
> if not form.vars.field1 and not form.vars.field2:
> form.errors.field2='cannot be empty if field1 is
On Apr 2, 2010, at 5:14 PM, mdipierro wrote:
> db.table.field1.requires=IS_NULL_OR(IS_IPV4())
> db.table.field2.requires=IS_NULL_OR(IS_IPV4()) if request.vars.field1
> else IS_IPV4()
Ah, that's the one I remember. Now I have to decide between this approach and
Yarko's.
Nice to have two
>
On Apr 2, 2010, at 8:05 PM, mdipierro wrote:
> Yes. No one solution is obviously better. It is good to have some
> options.
Yarko's approach allows for a more general error message, at the expense of not
associating it with a particular input field. In my case, I think I see a way
of phrasing t
8 matches
Mail list logo