• 2751 views
  • 0 comments
  • loading...

IS_DATE_IN_RANGE()

This validator checks that a field value contains a valid datetime in the specified format, similar as IS_DATETIME validator, but but allows to specify a range. It is good practice to specify the format using the translation operator, in order to support different formats in different locales.




requires = IS_DATE_IN_RANGE(format=T('%Y-%m-%d'),

minimum=datetime.date(2008,1,1),
maximum=datetime.date(2009,12,31),
error_message='must be YYYY-MM-DD!')

Attributes / Arguments

It is good practice to specify the format using the translation operator, in order to support different formats in different locales.

requires = IS_DATE_IN_RANGE(format=T('%Y-%m-%d'), ...)

Sets the minimum date

requires = IS_DATE_IN_RANGE(..., minimum=datetime.date(2008,1,1), ...)

Maximum date

requires = IS_DATE_IN_RANGE(...,maximum=datetime.date(2009,12,31) )

Display error message

requires = IS_DATE_IN_RANGE(..., error_message='must be YYYY-MM-DD!')


Examples

loading...


Comments

loading...

Powered by
Web2py

Hosted on
www.pythonanywhere.com
(affiliated link)