コード例 #1
0
ファイル: user.py プロジェクト: Roxerg/HtB2020
class UserValidator(Validator):

    email = StringField(required=True,
                        validators=[validate_email(), validate_email_unique])
    name = StringField(required=True, validators=[validate_not_empty()])
    description = StringField(required=True, validators=[validate_not_empty()])
    location = StringField(required=False)

    class Meta:
        messages = {
            'email_unique':
            'This email has already been used, please use another or log in.'
        }
コード例 #2
0
class SimpleValidator(Validator):
    name = StringField(validators=[
        validate_not_empty(),
        validate_length(3, 99),
        validate_regexp('^[a-zA-Z ]*$')
    ])
    email = StringField(validators=[validate_email()])
    art_name = StringField(
        validators=[validate_not_empty(),
                    validate_length(3, 99)])
    art_price = DecimalField(
        validators=[validate_not_empty(),
                    validate_range(1, 9999)])
    availability = StringField(validators=[validate_one_of(['yes', 'no'])])
コード例 #3
0
ファイル: FilmValidator.py プロジェクト: DoooMer/film-library
class FilmValidator(ModelValidator):
    title = StringField(validators=[validate_not_empty()], required=True)
    year = IntegerField(required=True)

    class Meta:
        messages = {
            'title.empty': "\"Название\" не заполнено",
            'year.coerce_int': "\"Год выхода\" не заполнено"
        }
コード例 #4
0
ファイル: forms.py プロジェクト: OzRayan/Taxi_Booking_System
class DriverForm(BaseForm):
    """DriverForm class for driver registration input validation.
    This class use the BaseForm class.
    Added field for registration number.
    :inherit: BaseForm
    """
    reg_nr = StringField(required=True,
                         max_length=40,
                         validators=[validate_not_empty()])
コード例 #5
0
def test_validate_not_empty():
    validator = validate_not_empty()

    for value in ('', '  '):
        field.value = value
        with pytest.raises(ValidationError):
            validator(field, {})

    for value in (None, 'alright', '123'):
        field.value = value
        validator(field, {})
コード例 #6
0
ファイル: forms.py プロジェクト: OzRayan/Taxi_Booking_System
class BaseForm(Validator):
    """BaseForm class for input validation. It makes sure that input fields are not empty
    and the email is a valid email.
    :inherit: Validator from peewee_validates"""
    first_name = StringField(required=True,
                             max_length=40,
                             validators=[validate_not_empty()])
    last_name = StringField(required=True,
                            max_length=40,
                            validators=[validate_not_empty()])
    username = StringField(required=True,
                           max_length=40,
                           validators=[validate_not_empty()])
    email = StringField(required=True,
                        max_length=40,
                        validators=[validate_not_empty(),
                                    validate_email()])
    password = StringField(required=True,
                           max_length=40,
                           validators=[validate_not_empty()])
コード例 #7
0
def test_validate_not_empty():
    validator = validate_not_empty()

    for value in ('', '  '):
        field.value = value
        with pytest.raises(ValidationError):
            validator(field, {})

    for value in (None, 'alright', '123'):
        field.value = value
        validator(field, {})
コード例 #8
0
 class TestValidator(Validator):
     field1 = StringField(required=False, validators=[validate_not_empty()])