當前位置: 首頁>>代碼示例>>Python>>正文


Python validators.NumberRange方法代碼示例

本文整理匯總了Python中wtforms.validators.NumberRange方法的典型用法代碼示例。如果您正苦於以下問題:Python validators.NumberRange方法的具體用法?Python validators.NumberRange怎麽用?Python validators.NumberRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wtforms.validators的用法示例。


在下文中一共展示了validators.NumberRange方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: handle_integer_types

# 需要導入模塊: from wtforms import validators [as 別名]
# 或者: from wtforms.validators import NumberRange [as 別名]
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) 
開發者ID:jpush,項目名稱:jbox,代碼行數:7,代碼來源:orm.py

示例2: conv_MSYear

# 需要導入模塊: from wtforms import validators [as 別名]
# 或者: from wtforms.validators import NumberRange [as 別名]
def conv_MSYear(self, field_args, **extra):
        field_args['validators'].append(validators.NumberRange(min=1901, max=2155))
        return f.TextField(**field_args) 
開發者ID:jpush,項目名稱:jbox,代碼行數:5,代碼來源:orm.py

示例3: get_IntegerField

# 需要導入模塊: from wtforms import validators [as 別名]
# 或者: from wtforms.validators import NumberRange [as 別名]
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) 
開發者ID:jpush,項目名稱:jbox,代碼行數:10,代碼來源:ndb.py

示例4: get_IntegerField

# 需要導入模塊: from wtforms import validators [as 別名]
# 或者: from wtforms.validators import NumberRange [as 別名]
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) 
開發者ID:jpush,項目名稱:jbox,代碼行數:10,代碼來源:db.py

示例5: convert_RatingProperty

# 需要導入模塊: from wtforms import validators [as 別名]
# 或者: from wtforms.validators import NumberRange [as 別名]
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) 
開發者ID:jpush,項目名稱:jbox,代碼行數:6,代碼來源:db.py

示例6: scaffold_form

# 需要導入模塊: from wtforms import validators [as 別名]
# 或者: from wtforms.validators import NumberRange [as 別名]
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 
開發者ID:radremedy,項目名稱:radremedy,代碼行數:34,代碼來源:reviewview.py

示例7: get_field_args

# 需要導入模塊: from wtforms import validators [as 別名]
# 或者: from wtforms.validators import NumberRange [as 別名]
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 
開發者ID:radremedy,項目名稱:radremedy,代碼行數:54,代碼來源:remedy_utils.py


注:本文中的wtforms.validators.NumberRange方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。