def mongoengine_validate_wrapper(old_clean, new_clean):
    """
    A wrapper function to validate formdata against mongoengine-field
    validator and raise a proper django.forms ValidationError if there
    are any problems.
    """

    def inner_validate(value):
        value = old_clean(value)
        try:
            new_clean(value)
            return value
        except __HOLE__, e:
            raise forms.ValidationError(e)
    return inner_validate
dataset/ETHPy150Open stephrdev/django-mongoforms/mongoforms/utils.py/mongoengine_validate_wrapper