Python wtforms.validators.Required() Examples

The following are 2 code examples of wtforms.validators.Required(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wtforms.validators , or try the search function .
Example #1
Source File: reviewview.py    From radremedy with Mozilla Public License 2.0 6 votes vote down vote up
def scaffold_form(self):
        """
        Sets up the review form to ensure that the rating field
        behaves on a 1-5 scale.
        """
        form_class = super(ReviewView, self).scaffold_form()

        form_class.rating = IntegerField(
            review_column_labels['rating'],
            validators=[
                validators.Required(),
                validators.NumberRange(min=1, max=5)
            ]
        )

        form_class.staff_rating = IntegerField(
            review_column_labels['staff_rating'],
            validators=[
                validators.Optional(),
                validators.NumberRange(min=1, max=5)
            ]
        )

        form_class.intake_rating = IntegerField(
            review_column_labels['intake_rating'],
            validators=[
                validators.Optional(),
                validators.NumberRange(min=1, max=5)
            ]
        )

        return form_class 
Example #2
Source File: __init__.py    From url-abuse with GNU Affero General Public License v3.0 5 votes vote down vote up
def authenticate():
    """Sends a 401 response that enables basic auth"""
    return Response('Could not verify your access level for that URL.\n'
                    'You have to login with proper credentials', 401,
                    {'WWW-Authenticate': 'Basic realm="Login Required"'})