Exemplo n.º 1
0
def test_validate_email():
    validator = validate_email()

    for value in ('bad', '())@asdfsd.com', 'tim@().com', [123, 123]):
        field.value = value
        with pytest.raises(ValidationError):
            validator(field, {'other': 'yes'})

    for value in (None, '*****@*****.**', 'tim@localhost'):
        field.value = value
        validator(field, {'other': 'yes'})
Exemplo n.º 2
0
    class CustomValidator(ModelValidator):
        first_name = StringField(required=True)
        username = StringField(required=True)
        email = StringField(required=True, validators=[validate_email()])
        password = StringField(required=True)

        class Meta:
            messages = {
                "email.validators": "Email address is invalid.",
                "required": "This field is required."
            }
Exemplo n.º 3
0
def test_validate_email():
    validator = validate_email()

    for value in ('bad', '())@asdfsd.com', 'tim@().com', [123, 123]):
        field.value = value
        with pytest.raises(ValidationError):
            validator(field, {'other': 'yes'})

    for value in (None, '*****@*****.**', 'tim@localhost'):
        field.value = value
        validator(field, {'other': 'yes'})
Exemplo n.º 4
0
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.'
        }
Exemplo n.º 5
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'])])
Exemplo n.º 6
0
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()])
Exemplo n.º 7
0
 class TestValidator(Validator):
     email = StringField(validators=[validate_email()])
Exemplo n.º 8
0
 class CustomValidator(ModelValidator):
     email = StringField(required=True, validators=[validate_email()])
Exemplo n.º 9
0
 class CustomValidator(ModelValidator):
     name = StringField(required=True)
     email = StringField(required=True, validators=[validate_email()])
     username = StringField(required=True)
     password = StringField(required=True)