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.

Source Distribution

vlight-1.2.1.tar.gz (4.8 kB view hashes)

Uploaded source

Built Distribution

vlight-1.2.1-py3-none-any.whl (4.9 kB view hashes)

Uploaded py3

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