Smart reusable validators for Django models & forms.
Project description
django-smart-validate
Smart reusable validators for Django models & forms.
django-smart-validate provides a collection of pre-built, reusable validators
and a mixin for applying them easily in Django models or forms.
Features
- Ready-to-use common validation patterns (slug, alpha-numeric, phone, email, etc.)
- Simple API for custom regex patterns
- Works in both Django models and forms
- Lightweight, no extra dependencies except Django
Installation
pip install django-smart-validate
Usage In a Django Model
from django.db import models
from smart_validate.validators import SmartValidator
class MyModel(models.Model):
user_code = models.CharField(max_length=10, validators=[SmartValidator.validator("code")])
email = models.CharField(max_length=254, validators=[SmartValidator.email()])
In a Django Form with Mixin
from django import forms
from smart_validate.validators import SmartValidator
from smart_validate.mixins import SmartValidateMixin
class MyForm(SmartValidateMixin, forms.Form):
name = forms.CharField()
email = forms.CharField()
smart_validators = {
"name": SmartValidator.validator("alpha_numeric"),
"email": SmartValidator.email(),
}
Available Validators
SmartValidator.validator("alpha_numeric")
SmartValidator.validator("slug")
SmartValidator.validator("phone")
SmartValidator.validator("code")
SmartValidator.email()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_smart_validate-0.1.0.tar.gz.
File metadata
- Download URL: django_smart_validate-0.1.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47935576b5c1c2cb685708fbb93101511059d9062546c47c985b6c018e0dcc75
|
|
| MD5 |
b42ebcb9f1fdfceab773bd331adb73d8
|
|
| BLAKE2b-256 |
4986f838826b5dc373805381cffe7a2cae780cc411880939eb65ff62d2f5a47c
|
File details
Details for the file django_smart_validate-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_smart_validate-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3319fd271bbfa31a1f9eb76aeb3ad32e5be6c0d9d6eb0191857a88baffe97ca6
|
|
| MD5 |
c218c9361aea3b9d4a0f99446944c154
|
|
| BLAKE2b-256 |
03a259b26f0fb0a41a18d46ab9b7bd8cab1ff6910523c66b4467e9b3411304ed
|