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')
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
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()
def validate_password(self, value): dbobj = orm_User.get(user.id) if not dbobj.validate_password(value): raise ValueInvalid('incorrect password') return value
def validate_password_complexity(self, value): ret = validate_password_complexity(value) if isinstance(ret, six.string_types): raise ValueInvalid(ret) return value
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)
def validator(form): try: f.elements.myfield.value except ElementInvalid as e: raise ValueInvalid(e)
def test_invalid_exc(): e = ValueInvalid(ValueError('foo')) assert str(e) == 'foo'
def test_invalid_str(): e = ValueInvalid('foo') assert str(e) == 'foo'