Skip to main content

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|int",
    "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", "int"],
    "email": ["required", "email"],
    "first_name": ["required", "string"],
    "last_name": ["required", "string"],
    "password": ["required", "min:8", "max:255"],
}

The full documentation can be found here.

Metadata

Release files for spotlight 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spotlight 2.2.0
File Size Uploaded Provenance
spotlight-2.2.0.tar.gz 25.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for spotlight 2.2.0
File Interpreter ABI Platform
spotlight-2.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 37.6 kB

Release files / spotlight-2.2.0.tar.gz

Download URL spotlight-2.2.0.tar.gz
Size 25.0 kB
Tags Source
SHA-256 checksum
How to use checksums
37b64d64bc6ce2af8b5a1807db49375d9399a1b937e7d59e89baddd9c10540c0
BLAKE2b-256 checksum
How to use checksums
d955931746d7467050097475628d64629d8df245294b9806d7ad3c7e6b4098af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.3

Release files / spotlight-2.2.0-py3-none-any.whl

Download URL spotlight-2.2.0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
817920adf1a1d1a64db85e6387364ef856e254feab24a91c7ca38374e64f6680
BLAKE2b-256 checksum
How to use checksums
6a99227f6a3ffe33d7992b778b6843f03ca61acf2352be1bbe4dad7239671323
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.3

Security for spotlight 2.2.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.

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page