Beispiel #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')
Beispiel #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
Beispiel #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()
Beispiel #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
Beispiel #5
0
 def validate_password_complexity(self, value):
     ret = validate_password_complexity(value)
     if isinstance(ret, six.string_types):
         raise ValueInvalid(ret)
     return value
Beispiel #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)
Beispiel #7
0
 def validator(form):
     try:
         f.elements.myfield.value
     except ElementInvalid as e:
         raise ValueInvalid(e)
Beispiel #8
0
def test_invalid_exc():
    e = ValueInvalid(ValueError('foo'))
    assert str(e) == 'foo'
Beispiel #9
0
def test_invalid_str():
    e = ValueInvalid('foo')
    assert str(e) == 'foo'