On Jan 11, 2:57 pm, mdipierro <[email protected]> wrote: > You can create your own field-level validators > > class validator: > def __init__(self,error_message): self.error_message=error_message > def __call__(self,value): > if success: return (value,None) > else: return (value,self.error_message)
Yes of course, but I thought some "stock" date validators are worth to discuss. There are IS_INT_IN_RANGE and friends, then why not IS_DATE_IN_RANGE (maybe with defaults to None for both min and max date). > both form.accept and crud.create/crud.update take a parameter > onvalidation > > onvalidation can point to a function that takes a form, reads > form.vars and writes form.errors > > def f(form): > if not form.vars.a==form.vars.b: form.errors.b="should be == a" > form = crud.create(...., onvalidation = f) But this way the validation is not built into the form/model :( > > On Jan 11, 6:13 am, "KONTRA, Gergely" <[email protected]> wrote: > > > Hi! > > I have a status "enumeration" for a status in one of my tables. I'd > > like to store it, as an integer, and access it with constants. Where > > should I define these constants (I guess I should in db.py), and how > > can I access them in the controller? > > > And some random things about validators: > > date validation: I miss a date validator, which allows dates > > before/after a specific date or at least current time. > > > validators: despite of the names is_*, they do not do just checking, > > they perform type conversions, change appearance of a form widget ... > > (Currently I have no idea of better names) > > > Multi-field validation is not currently possible AFAIK. (As I can see, > > you can skip dbio, and validate manually). However, for transparent > > model validation, it would be necessary. So, your data is validated > > upon a plain insert. > > Isn't it possible to have some optional validation hook, in term of a > > function, which gets all the form data, and can judge about the > > validation of the form? This validator should be able to signal errors > > like: field a should be greater than field b, or: if a is empty, b > > could be anything (it is ignored). > > > thanks > > Gergo > > > +-[ Gergely Kontra <[email protected]> ]------------------+ > > | | > > | Mobile:(+36 20)356 9656 | > > | | > > +- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+
-- You received this message because you are subscribed to the Google Groups "web2py-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/web2py?hl=en.

