Skip to main content

Data validation for Python, inspired by the Laravel framework.

Project description


Data validation for Python, inspired by the Laravel framework.



Source Code:



Spotlight can be installed via pip:

pip install spotlight


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": "",
    "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.

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

spotlight-3.1.0.tar.gz (29.3 kB view hashes)

Uploaded Source

Built Distribution

spotlight-3.1.0-py3-none-any.whl (13.1 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