Skip to main content

Thư viện validate dữ liệu đầu vào

Project description

Validator là thư viện validate dữ liệu input


Phiên bản hiện tại 0.1

Cài đặt:

pip3 install m-validator

Sử dụng:

rules = {
    'key1': [Required, InstanceOf(str)],
    'status': [InstanceOf(int), In([1,2,3])],
    'lang': []
data1 = {
    'key1': 'abc',
    'status': 1,
    'lang': 'vi'
data2 = {
    'status': 1,
    'lang': 'vi'
valid = HttpValidator(rules)
val_result = valid.validate_object(data1)
if not val_result[VALIDATION_RESULT.VALID]:
    errors = val_result[VALIDATION_RESULT.ERRORS]
    raise ParamInvalidError(LANG.VALIDATE_ERROR, errors)

data1 --> OK
data2 --> Fail, key1 must be present

Project details

Release history Release notifications | RSS feed

This version


Download files

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

Files for m-validator, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size m_validator-0.1-py3-none-any.whl (8.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size m-validator-0.1.tar.gz (8.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page