Skip to main content

a simple package for validation data

Project description


simple package for validation data

Getting Started


if you have old version do this:

pip uninstall vlight

and to install latest version : pip install vlight

use vlight

from vlight import v


validate a simple login form with email :

from vlight import valid # also you can use "v" helper method

vlight in django

create validation rules and set data

from vlight import v
valid = v({
    "email": "req|email",
    "password": "req|min:8|max:255"
}, data={
    "password": "123" # this field have minimum character error
#check data is valid

if valid.isOk():
    # submit your form

#check have error
if valid.fails():

#check a field have error

if error.has("email"):
    #this block run when your email field have error

#get field errors messages
# you can set returned error length

#customize error messages

#to customize all fields default messages:
valid = v({
    "email": "required|email",
    "password": "required|min:8|max:255"
}, data={
    "password": "123"
    "required":"{field} required ",
    "email": "email field with value [{value}] not valid",

#or you can customize only a field messages
valid = v({
    "email": "required|email"
    "|required.msg:enter your email"
    "|email.msg:email is not valid",

    "password": "required|min:8|max:255"
    "|str.min:your password is easy"
    "|str.max:your selected password so hard"
}, data={
    "password": "123"
an example in django

from django.shortcuts import render
from vlight import v

def index(request, **kwargs):
    msgs = []
    if request.method == "POST":

        valid = v({
            "email": "required|email",
            "password": "required|min:8|max:255"
        }, data=request.POST)

        if valid.fails():
            msgs = valid.errors().all()
            msgs.append("your form submitted!")

    return render(request, "index.html", {"login_errors": msgs}) 

index.html jinja2

<form action="/" method="post">
    <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
    <label for="email">email:</label>
    <input id="email" type="text" name="email">
    <label for="password">password:</label>
    <input id="password" type="password" name="password">
    <input type="submit" value="login">
    {% for error in login_errors %}
        <li><a href="#">{{ error }}</a></li>
    {% endfor %}

supported rules

required check data has field and data is not empty


email pattern : ^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$


ip pattern : ^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$


url pattern : ^http(s?):\/\/(www\.)?(((\w+(([\.\-]{1}([a-z]{2,})+)+)(\/[a-zA-Z0-9\_\=\?\&\.\#\-\W]*)*$)|(\w+((\.([a-z]{2,})+)+)(\:[0-9]{1,5}(\/[a-zA-Z0-9\_\=\?\&\.\#\-\W]*)*$)))|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}(([0-9]|([1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]+)+)(\/[a-zA-Z0-9\_\=\?\&\.\#\-\W]*)*)((\:[0-9]{1,5}(\/[a-zA-Z0-9\_\=\?\&\.\#\-\W]*)*$)*))$


not_in in check value in items


regex not_regex coming soon

ext check path extension


int integer validation


max set maximum character of string


and you can change the rule for int value to check max integer value

[ more validation rules will added coming soon ]

develop your rule

docs coming soon

latest version changes


  • fix bugs



This project is licensed under the MIT License

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for vlight, version 1.2.1
Filename, size File type Python version Upload date Hashes
Filename, size vlight-1.2.1-py3-none-any.whl (4.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size vlight-1.2.1.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page