Skip to main content

Spotlight

Data validation for Python, inspired by the Laravel framework.

Coverage

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.0.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 3.0.0
File Size Uploaded
spotlight-3.0.0.tar.gz 29.1 kB Details

Built distribution (wheel)

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

Total release size: 42.1 kB

Release files / spotlight-3.0.0.tar.gz

Download URL spotlight-3.0.0.tar.gz
Size 29.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9acead51227a29111721f6fd91464cc8c58adb62c4df67bbba716311195eff87
BLAKE2b-256 checksum
How to use checksums
86551761fd29d0e50d1a50e1dcb5c27b996532b30ef6c12e76c363500187b9ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.0.0 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.14

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

Download URL spotlight-3.0.0-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6fc6d9414cd7c93576d1d7837b2fe47219515f4d8fb236592bad9e12b8acd2d
BLAKE2b-256 checksum
How to use checksums
0613895db43734dbbe1b99038efd900117992efa4d33ed6726e90d5df5840dd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.0.0 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.14

Release history Release notifications | RSS feed

3.4.0

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.1

2 release files

This release

3.0.0 This release

2 release files

2.3.3

2 release files

2.3.2

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

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