Skip to main content

AVal is a class capable of applying a list of validation strategies and an exception handler to an object to be validated. It can be used by calling the validation method as well as a decorator

Project description

aval

Abstract

Abstract Validator (AVal) is a class implemented in Python, capable of taking a list of specific validation strategies (with parameters), as well as a method for handling exceptional situations, and applying these methods to the validation object. The Abstract Validator can be used by calling the validation method on an instance of a class, as well as a decorator.

Installation

Use:

pip install aval

Basic usage

def _is_string(obj: v.VObj, params: v.VParams) -> None:
    t = type(obj)
    if t != str:
        raise v.ValidationError('Some description')


def _correct_length(obj: v.VObj, params: v.VParams) -> None:
    mn = params.get('min_length', 1)
    mx = params.get('max_length', 32)
    ln = len(obj)
    if not mn <= ln <= mx:
        raise v.ValidationError('Some description'
        )


vld = v.Validator([_is_string, _correct_length])
vld.validate('Any message')

Details

More detailed documentation (in Russian) can be found at https://docs.mxustin.ru/micro/validator/manual/intro

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aval-0.0b1.tar.gz (6.0 kB view hashes)

Uploaded Source

Built Distribution

aval-0.0b1-py3-none-any.whl (7.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page