Skip to content

Validation package to validate incoming data

Notifications You must be signed in to change notification settings

girardinsamuel/validation

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Masonite Validation

This package is a standalone component package for the Masonite framework.

Masonite comes with this package out of the box but you can also use this package by itself.

Installing this package does not install the Masonite framework. This only installs the few modules necessary to have validation.


Installation

First pip install it:

$ pip install masonite-validation

Getting Started

To use this package you can import the Validator class at the top:

from masonite.validation import Validator

As well as some rules:

from masonite.validation import Validator, required, exists, accepted

And then specify the rules in this format:

# Validator({dictionary}, *rules, **kwargs)

So for example to validate this payload:

payload = {
    'user': 'username123',
    'company': 'Masonite',
    'terms': 'on' # For checkboxes
}

errors = Validator(
    payload,
    required(['user', 'company', 'terms']),
    accepted('terms')
  )

Errors will either be nothing or an dictionary of error messages

Documentation

You can find extension documentation on available rules at the Masonite Documentation

About

Validation package to validate incoming data

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 97.9%
  • HTML 2.1%