Massimo, I will try this. However, I've noticed that with the latest release 1.67.1 that the IS_NULL_OR(IS_UPLOAD_FILENAME()) and IS_NULL_OR (IS_IMAGE()) both seem to work in a manner that the IS_NULL_OR takes precedence in cases where the filename or image fields are empty. Did you make a change to support this, from now on? If not, then something strange is going on that it's working all of a sudden.
On Sep 16, 12:41 am, mdipierro <[email protected]> wrote: > try this > > class MYVALIDATOR: > def __call__(self,value): > if not value: return (value,None): > ret = IS_UPLOAD_FILENAME()(value) > if ret[1]: return ret > ret = IS_IMAGE()(value) > return ret > > requires=MYVALIDATOR() > > On Sep 15, 9:38 pm, weheh <[email protected]> wrote: > > > > > Massimo, the real question is how to write a validator if a file or > > image upload field's value is optional? So it can be NULL or some > > other value that either conforms to filename conventions (in the case > > of IS_UPLOAD_FILENAME()) or image naming conventions (in the case of > > IS_IMAGE()). In both cases, if a file is supplied, I want to also > > validate the size of the file.- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

