Python wtforms.validators.NumberRange() Examples
The following are 17
code examples of wtforms.validators.NumberRange().
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 |
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: orm.py From jbox with MIT License | 5 votes |
def conv_MSYear(self, field_args, **extra): field_args['validators'].append(validators.NumberRange(min=1901, max=2155)) return f.TextField(**field_args)
Example #3
Source File: db.py From googleapps-message-recall with Apache License 2.0 | 5 votes |
def convert_RatingProperty(model, prop, kwargs): """Returns a form field for a ``db.RatingProperty``.""" kwargs['validators'].append(validators.NumberRange(min=0, max=100)) return f.IntegerField(**kwargs)
Example #4
Source File: db.py From googleapps-message-recall with Apache License 2.0 | 5 votes |
def get_IntegerField(kwargs): """ Returns an ``IntegerField``, applying the ``db.IntegerProperty`` range limits. """ v = validators.NumberRange(min=-0x8000000000000000, max=0x7fffffffffffffff) kwargs['validators'].append(v) return f.IntegerField(**kwargs)
Example #5
Source File: ndb.py From googleapps-message-recall with Apache License 2.0 | 5 votes |
def get_IntegerField(kwargs): """ Returns an ``IntegerField``, applying the ``ndb.IntegerProperty`` range limits. """ v = validators.NumberRange(min=-0x8000000000000000, max=0x7fffffffffffffff) kwargs['validators'].append(v) return f.IntegerField(**kwargs)
Example #6
Source File: orm.py From googleapps-message-recall with Apache License 2.0 | 5 votes |
def conv_MSYear(self, field_args, **extra): field_args['validators'].append(validators.NumberRange(min=1901, max=2155)) return f.TextField(**field_args)
Example #7
Source File: orm.py From googleapps-message-recall with Apache License 2.0 | 5 votes |
def handle_integer_types(self, column, field_args, **extra): unsigned = getattr(column.type, 'unsigned', False) if unsigned: field_args['validators'].append(validators.NumberRange(min=0)) return f.IntegerField(**field_args)
Example #8
Source File: db.py From RSSNewsGAE with Apache License 2.0 | 5 votes |
def convert_RatingProperty(model, prop, kwargs): """Returns a form field for a ``db.RatingProperty``.""" kwargs['validators'].append(validators.NumberRange(min=0, max=100)) return f.IntegerField(**kwargs)
Example #9
Source File: db.py From RSSNewsGAE with Apache License 2.0 | 5 votes |
def get_IntegerField(kwargs): """ Returns an ``IntegerField``, applying the ``db.IntegerProperty`` range limits. """ v = validators.NumberRange(min=-0x8000000000000000, max=0x7fffffffffffffff) kwargs['validators'].append(v) return f.IntegerField(**kwargs)
Example #10
Source File: ndb.py From RSSNewsGAE with Apache License 2.0 | 5 votes |
def get_IntegerField(kwargs): """ Returns an ``IntegerField``, applying the ``ndb.IntegerProperty`` range limits. """ v = validators.NumberRange(min=-0x8000000000000000, max=0x7fffffffffffffff) kwargs['validators'].append(v) return f.IntegerField(**kwargs)
Example #11
Source File: orm.py From RSSNewsGAE with Apache License 2.0 | 5 votes |
def conv_MSYear(self, field_args, **extra): field_args['validators'].append(validators.NumberRange(min=1901, max=2155)) return f.TextField(**field_args)
Example #12
Source File: orm.py From RSSNewsGAE with Apache License 2.0 | 5 votes |
def handle_integer_types(self, column, field_args, **extra): unsigned = getattr(column.type, 'unsigned', False) if unsigned: field_args['validators'].append(validators.NumberRange(min=0)) return f.IntegerField(**field_args)
Example #13
Source File: db.py From jbox with MIT License | 5 votes |
def convert_RatingProperty(model, prop, kwargs): """Returns a form field for a ``db.RatingProperty``.""" kwargs['validators'].append(validators.NumberRange(min=0, max=100)) return f.IntegerField(**kwargs)
Example #14
Source File: db.py From jbox with MIT License | 5 votes |
def get_IntegerField(kwargs): """ Returns an ``IntegerField``, applying the ``db.IntegerProperty`` range limits. """ v = validators.NumberRange(min=-0x8000000000000000, max=0x7fffffffffffffff) kwargs['validators'].append(v) return f.IntegerField(**kwargs)
Example #15
Source File: ndb.py From jbox with MIT License | 5 votes |
def get_IntegerField(kwargs): """ Returns an ``IntegerField``, applying the ``ndb.IntegerProperty`` range limits. """ v = validators.NumberRange(min=-0x8000000000000000, max=0x7fffffffffffffff) kwargs['validators'].append(v) return f.IntegerField(**kwargs)
Example #16
Source File: orm.py From jbox with MIT License | 5 votes |
def handle_integer_types(self, column, field_args, **extra): unsigned = getattr(column.type, 'unsigned', False) if unsigned: field_args['validators'].append(validators.NumberRange(min=0)) return f.IntegerField(**field_args)
Example #17
Source File: remedy_utils.py From radremedy with Mozilla Public License 2.0 | 4 votes |
def get_field_args(field, **kwargs): """ Generates a dictionary of arguments to be used when rendering out a form field. Args: field: The form field to render. **kwargs: Any additional arguments to include for the form field. Returns: A dictionary of arguments to use to render out a form field. """ # Set up our default args field_args = { "class_": "form-control" } # Handle required fields if field.flags.required: field_args['required'] = 'required' # Look at field validators for val in field.validators: # Handle minlength/maxlength attributes if specified on # string fields through a Length validator if isinstance(val, Length): if val.min > 0: field_args['minlength'] = val.min if val.max > 0: field_args['maxlength'] = val.max elif isinstance(val, Email): field_args['type'] = 'email' elif isinstance(val, URL): field_args['type'] = 'url' elif isinstance(val, NumberRange): if val.min is not None: field_args['min'] = val.min if val.max is not None: field_args['max'] = val.max # If we have a description, create an aria-described by attribute if field.description and len(field.description) > 0: field_args['aria-describedby'] = field.id + '_help' # Merge in extra arguments field_args.update(kwargs) # Default rows for textareas if not specified if 'rows' not in field_args and field.type == 'TextAreaField': field_args['rows'] = '3' return field_args