pyvalidate
Validates input parameters of a callable using this arguments:
param: arg_types: list of types, Required argument's types & counts in order param: deny_match list of string ,regex pattern, if any argument matches with the pattern, exception raises param: requires: list of fields to check for mandatory param: deny: string ,regex pattern, if any parameter matches with the pattern, exception raises param: deny_except: string ,regex pattern for excluding fields from deny param: types: dict of key:name and value:type to check for types, if mismatch it will be raises exception param: values: dict of key:name and value:regex pattern to check the values, & fire exception if mismatch param: ignore: string ,regex pattern of parameters to filter param: defaults: dict of key:name and value:default_value
Exceptions:
raise: MandatoryException: if any param in requires does not provided raise: ArgumentException: if arguments are invalid , short or mismatch type. raise: DenialException: if found param in deny list raise: ParameterTypeException: if parameter types invalid raise: ParameterValueException: if values are not in correct format
Example:
from pyvalidate import validate, ValidationException
@validate(arg_types=[int, str, str],
deny_match=['xxx', 'tiktik'],
requires=['phone'],
deny='query',
deny_except='query2',
types={'phone':str, 'address':str, 'age':int},
values={'phone':'^\d*$'},
ignore='age',
defaults={'address':'nothing'})
def add_person(serial, firstname, lastname, phone=None, address=None, age=None, **kw):
print 'adding person "%s:%s %s:%s" with serial: %s:%s phone: %s:%s address: %s:%s age:%s:%s' % (firstname, type(firstname),
lastname, type(lastname),
serial, type(serial),
phone,
type(phone),
address,
type(address),
age,
type(age))
def test(*args, **kwargs):
try:
add_person(*args, **kwargs)
except ValidationException as ex:
print ex.message
def main():
test(12, "Vahid", "Mardani", phone="09122451075", address="Tehran")
test("12", "Vahid", "Mardani", phone='+9122451075', address="Tehran")
test("12", "Vahid", "Mardani", phone='1')
test("12", "Vahid", "Mardani", phone='tiktik')
test("12", "xxx", "Mardani", phone='')
test("12", "", "Mardani",)
test("12", "", "Mardani", phone='1', query='123')
test("12", "", "Mardani", phone='1', query2='123')
test("12", "", "Mardani", phone='1', age='123')
if __name__ == '__main__':
main()
Metadata
Release files for pyvalidate 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyvalidate-1.3.1.tar.gz | 3.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyvalidate-1.3.1-py2.7.egg | Legacy Egg format | - | - | Details |
Total release size: 10.7 kB
Release files / pyvalidate-1.3.1.tar.gz
| Download URL | pyvalidate-1.3.1.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
564be484820432e052f2bc23d29165822d56f71d5ff6ce8040cd4643c28a3a97
|
|
BLAKE2b-256 checksum How to use checksums |
ea92c2303c5adaff4ffc2313e7afec91f169372a7b6922d40ab46fd83a67153f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pyvalidate-1.3.1-py2.7.egg
| Download URL | pyvalidate-1.3.1-py2.7.egg |
|---|---|
| Size | 6.8 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
bfb49447d1d0c060fdea8efc7710b8f66b6cd8e14d60362fc1736a8c660ae5f1
|
|
BLAKE2b-256 checksum How to use checksums |
8ef5c2aa47ddeaba61008f8d2c6ac15a3ab3160eb84a9783971159689a7c837e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pyvalidate 1.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.