Skip to content

Latest commit

 

History

History
83 lines (62 loc) · 1.89 KB

validators.rst

File metadata and controls

83 lines (62 loc) · 1.89 KB

Validators

Validators are ordinary callables that take a single argument (the input value) and return a transformed result value. They can also raise validation errors.

IValidator(value)

Validates the input value and possibly transforms it.

Returns the new value. If the value is invalid, raises a decent.error.Error or decent.error.Invalid exception.

Validator callables can be used inside schemas, but also standalone.

Built-in validators

Decent ships with many built-in validators that can be used and combined for usual tasks. Instances of them are built through the following constructors:

Helpers & Building blocks

decent.validators.All

decent.validators.Any

decent.validators.Default

decent.validators.Maybe

decent.validators.Msg

Basics

decent.validators.Eq

decent.validators.Coerce

decent.validators.Instance

decent.validators.Type

Collections

decent.validators.List

decent.validators.Length

Booleans

decent.validators.Boolean

Numbers

decent.validators.Range

decent.validators.Length

Strings

decent.validators.Lower

decent.validators.Upper

decent.validators.Strip

decent.validators.Length

String conversions

decent.validators.Uuid