Introduction
Web2py is a full-stack web framework based on Python. It is an easy-to-learn, fast, secure and reliable framework. Now, in each framework, we have some validators which check the correctness of input fields that is taken by forms. Validators are mainly used to validate the field created by forms so that it becomes easy for users to keep a check on the application. We can add a single validator or multiple validators, depending on our needs. This always comes with the “require” attribute in web2py.

In this blog, we will learn about range, set and equality validators.
Range, set and equality validators in web2py
Let’s start discussing variants of range, set and equality validators one by one.

IS_EQUAL_TO
This validator is used to check whether the field input value equals the given desired value.
requires = IS_EQUAL_TO(request.vars.password, error_message='wrong password! Check again')
IS_NOT_EMPTY
This validator is used to check that none of the fields remains empty.
requires = IS_NOT_EMPTY(error_message='Must have some value!')IS_NULL_OR
This validator is used to allow an input field to have NULL as a value given. Say, for example, middle name.
IS_EMPTY_OR
This validator is used to allow an input field to remain empty. Say, for example, society name in address or date.
requires = IS_EMPTY_OR(IS_DATE())IS_EXPR
This validator is used to check for the correctness of a given condition.
requires = IS_EXPR(lambda v: T('not a prime number') if int(v) a prime number else None)IS_DECIMAL_IN_RANGE
This validator is used to convert the inputted value to a decimal of a given range. If it can’t be converted, then it throws an error.
INPUT(_type='text', _name='name', requires=IS_DECIMAL_IN_RANGE(0, 100))IS_FLOAT_IN_RANGE
This validator is used to check for the floating point number in a given range. Minimum and maximum values of the range are decided by the user.
IS_INT_IN_RANGE
This validator is used to check for the integer value in a given range. Minimum ana maximum values of the range are decided by the user.
requires = IS_INT_IN_RANGE(0, 100, error_message='not in a desired range!')IS_IN_SET
This validator is used to create a drop-down menu.
requires = IS_IN_SET(['pizza', 'burger', 'pasta'], zero=T('choose which one you would like to have’),error_message='choose only one')





