Validator-Schema
Esta é uma lib usada para validar que vem de um jsonschema em API Rest. A capacidade de validação dele vem de expressões regulares, strings, numeros, enums, datas (formato YYYY-MM-DD) e hora (formato HH:MM)
INSTALAÇÃO
Para realizar a instalação deste módulo basta executar
pip install validator-schema
UTILIZAÇÃO
Vamos supor que você tenha um servidor com Flask onde você vai receber por paramêtros um json e quer validar os campos name e password. Onde o name não deve vir vazio e password deve ter ao menos 8 caracteres. Isto pode ser validado de forma simples com o validator-schema
from flask import request
import json
from validator_schema import ValidatorString, Validator
...
@app.route('/', methods = ['POST'])
def login():
data = request.get_json()
list_validators = [
ValidatorString('name', min = 1, msg_error = 'Field name without value'),
ValidatorString('password', min = 8, msg_error = 'Field password minimum 8 caracters.)
]
requireds = ['name', 'password']
v = Validator(list_validators, requireds)
try:
v.is_valid(data)
except ValueError as err:
return json.dumps({'error': str(err)})
# Fields validates
Metadata
Release files for validator-schema 0.1.0
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 | Actions |
|---|---|---|---|---|
| validator_schema-0.1.0.tar.gz | 4.2 kB | Without provenance | Details for validator_schema-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| validator_schema-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for validator_schema-0.1.0-py3-none-any.whl |
Total release size: 9.0 kB
Release files / validator_schema-0.1.0.tar.gz
| Download URL | validator_schema-0.1.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bce45dcbe297701d321c4bf781927de7e108626cab0cb9193e565d6dd5c9f4ad
|
|
BLAKE2b-256 checksum How to use checksums |
b683c3d1a4686626dc35fe6783b9799105850116482c3297a3344e38c07149c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.10.6 Linux/5.19.0-43-generic
|
Release files / validator_schema-0.1.0-py3-none-any.whl
| Download URL | validator_schema-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10d5d24c3a8f523e89163c0a85ec4dc4633fdcbf2afa71eed5be567380522dfb
|
|
BLAKE2b-256 checksum How to use checksums |
43bd9b438dad813501e31e5d6c68eb1de278f2c56489c4c82e6be097b66902ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.10.6 Linux/5.19.0-43-generic
|
Security for validator-schema 0.1.0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.