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!

Lightweight field data validator.

Project Description

fivalid is lightweight field data validator.


data validation:

>>> from fivalid import validators
>>> num = validators.Number(max=20)
>>> num(10)
>>> num(21)
fivalid.validators.InvalidValueError: over max

data validation and conversion:

>>> from fivalid import BaseField, validators, converters
>>> class PercentageField(BaseField):
...   validator = validators.All(
...     validators.Number(min=0, max=100),
...     validators.String())
...   converter = converters.int_converter
>>> field = PercentageField()
>>> field('99')
>>> field('200')
fivalid.validators.InvalidValueError: over max

structured data (e.g. nested dict, nested list) validation and conversion:

>>> from fivalid import StructuredFields, Dict, BaseField
>>> from fivalid.validators import String, Length, All, Flag
>>> from fivalid.converters import truthvalue_converter
>>> class CommentField(BaseField):
...   validator = All(String(), Length(max=500))
>>> class NicknameField(BaseField):
...   validator = All(String(), Length(max=20))
>>> class RememberMeField(BaseField):
...   validator = Flag()
...   converter = truthvalue_converter
>>> rule = Dict(
...   {'comment': CommentField(required=True),
...    'nickname': NicknameField(),
...    'remember me': RememberMeField()}
... )
>>> stfields = StructuredFields(rule)
>>> stfields({'comment': 'Hello, fivalid.',
...           'nickname': 'John Doe',
...           'remember me': '1'}
... )
{'comment': u'Hello, fivalid.', 'nickname': u'John Doe', 'remember me': True}
Release History

Release History

This version
History Node


History Node


History Node


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 (17.2 kB) Copy SHA256 Checksum SHA256 Source Nov 11, 2012

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