Esempio n. 1
0
    def validate_perms(self, value):
        assigned = toset(self.elements.approved_permissions.value)
        denied = toset(self.elements.denied_permissions.value)

        if len(assigned.intersection(denied)) != 0:
            raise ValueInvalid(
                'you can not approve and deny the same permission')
Esempio n. 2
0
    def validate_email(self, value):
        dbobj = orm_User.get_by_email(value)
        if (dbobj is None):
            raise ValueInvalid('email address is not associated with a user')

        return value
Esempio n. 3
0
 def validate_validnew(self, form):
     if form.password.value == form.old_password.value:
         err = 'password must be different from the old password'
         form.password.add_error(err)
         raise ValueInvalid()
Esempio n. 4
0
    def validate_password(self, value):
        dbobj = orm_User.get(user.id)
        if not dbobj.validate_password(value):
            raise ValueInvalid('incorrect password')

        return value
Esempio n. 5
0
 def validate_password_complexity(self, value):
     ret = validate_password_complexity(value)
     if isinstance(ret, six.string_types):
         raise ValueInvalid(ret)
     return value
Esempio n. 6
0
 def validator(form):
     if form.elements.myfield.is_valid():
         if form.elements.myfield.value != 'foo':
             raise ValueInvalid('My Field: must be "foo", not "%s"' %
                                form.elements.myfield.value)
Esempio n. 7
0
 def validator(form):
     try:
         f.elements.myfield.value
     except ElementInvalid as e:
         raise ValueInvalid(e)
Esempio n. 8
0
def test_invalid_exc():
    e = ValueInvalid(ValueError('foo'))
    assert str(e) == 'foo'
Esempio n. 9
0
def test_invalid_str():
    e = ValueInvalid('foo')
    assert str(e) == 'foo'