Cleans the data and throws ValidationError on failure

def clean(self):
        """ Cleans the data and throws ValidationError on failure """
        errors = {}
        cleaned = {}

        for name, validator in self.validate_schema.items():
            val = getattr(self, name, None)
            try:
                cleaned[name] = validator.to_python(val)
            except formencode.api.Invalid, err:
                errors[name] = err

        if errors:
            raise ValidationError('Invalid data', errors)
        return cleaned