Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Minos is a library to do flexible validation of Python objects

Project Description
Minos: A Lightweight Validation Framework
`Minos` is a library that you can use in your code to create a simple validation
framework. Its aim is to provide a lightweight interface of functions that make it
simple to quickly build and manipulate models.

.. toctree::
:maxdepth: 2


To install Minos locally:


$ python develop

Minos will soon be on PyPi.

.. _Quickstart:


There are a few patterns Minos was designed to support; class validation with validators declared as
part of the class definition, class validation where the validators are declared seperately, and as
totally independant object validators. See below for a few examples of each pattern.

Class Validators in Class Definition

To declare validators inside of a class, the class needs to inherit from the Minos Mixin, and the
validation arguments are passed to each validator on instantiation.

For example, given a class definition like so:

.. sourcecode:: python

import minos
import pytz

from datetime import datetime
from minos.validators import DatetimeValidator, NumericalityValidator, PresenceValidator

class Toaster(minos.Mixin):


created_at = None
num_slots = None


validators = [
PresenceValidator('num_slots'), # every toaster needs to have its number of slots specified
#Toasters can only have an integer number of slots between 2-8

def __init__(self, bread):
self.bread = bread
self.created_at =

#...class definition continues...

When using the ToasterClass in code, you can do stuff like this:

.. sourcecode:: python

def toast_bread(bread):
toaster = Toaster(num_slots=4)
toaster.validate() # Validates that toaster's attributes are valid
except minos.errors.FormValidationError:
raise ToastError("can't toast bread, toasters busted.")

toasted_bread = toaster.toast(bread)

return toasted_bread

Class Validators Outside Class Definition

Similarly, You can also create a validator that validates a single attribute of a python object,
and pass objects to be validated to it using the Validator's *.validate_wrapper()* call.

.. sourcecode:: python

import minos
from minos.validators import NumericalityValidator

#Create a validator that for a toaster's slots ahead of time
slot_validator = NumericalityValidator(

#Given a list of toasters, validate them all
for toaster in [dorm_toaster, kitchen_toaster, fancy_toaster]:
#Check this toaster using the parameters specified earlier
except minos.errors.FormValidationError:
print "{} doesn't have the right number of slots.".format(

Single\-Use Validation

You can also create validators without configuration, and specify the configuration inline using the *.validate()* call:

.. sourcecode:: python

from minos.validators import NumericalityValidator
from minos.errors import ValidationError

#Make a validator that checks numeric qualities of objects
accountant = NumericalityValidator()

#Check a bunch of stuff

accountant.validate(bank_account, greater_than=0)
except ValidationError:
print "You're broke!"

accountant.validate(tax_payment, greater_than=0, less_than=5000.00)
except ValidationError:
print "You're tax payment doesn't seem right..."

accountant.validate(num_deductions, integer_only=True)
except ValidationError:
print "Your number of deductions doesn't make sense."
Release History

Release History

This version
History Node


History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Minos-0.1.2.tar.gz (13.3 kB) Copy SHA256 Checksum SHA256 Source Oct 7, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting