Spotlight
Data validation for Python, inspired by the Laravel framework.
Documentation: https://mdoesburg.github.io/spotlight/
Source Code: https://github.com/mdoesburg/spotlight
Requirements
Installation
Spotlight can be installed via pip:
pip install spotlight
Example
To validate data, we start by defining validation rules for each field we want to validate. After that, we pass the data and the validation rules into the Validator's validate method.
Lets have a look at a simple example:
from spotlight import Validator
rules = {
"id": "required|integer",
"email": "required|email",
"first_name": "required|string",
"last_name": "required|string",
"password": "required|min:8|max:255",
}
data = {
"id": 1,
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"password": "test",
}
validator = Validator()
errors = validator.validate(data, rules)
The validate method will return a dictionary of errors, if any occurred.
In the example above, the validate method will return the following errors:
{"password": ["The password field has to be at least 8 characters."]}
Alternatively, validation rules may be specified as lists of rules instead of a single | delimited string:
rules = {
"id": ["required", "integer"],
"email": ["required", "email"],
"first_name": ["required", "string"],
"last_name": ["required", "string"],
"password": ["required", "min:8", "max:255"],
}
The full documentation can be found here.
Release files for spotlight 3.4.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 | |
|---|---|---|---|
| spotlight-3.4.0.tar.gz | 30.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| spotlight-3.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.3 kB
Release files / spotlight-3.4.0.tar.gz
| Download URL | spotlight-3.4.0.tar.gz |
|---|---|
| Size | 30.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e7d6f58319615434dd57d80eb571f75d165d87d6fb7d7e170700c0350b7d00d
|
|
BLAKE2b-256 checksum How to use checksums |
0ff170bdd76358d58d68f1c402152149b68c84edbb7eefbb1186b24d30fec5b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.16
|
Release files / spotlight-3.4.0-py3-none-any.whl
| Download URL | spotlight-3.4.0-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f413b0a7d902368e9600ae879ee9ba1ba3506592c0de3c0b59d8cd29ddb52006
|
|
BLAKE2b-256 checksum How to use checksums |
8829ec27e9eb745f4053f6f8b797425928e1902dd7aa7d6fbd0d3dcd583a1240
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.16
|