Schema class

Class definition

class onctuous.schema.Schema(schema, required=False, extra=False)

A validation schema.

The schema is a Python tree-like structure where nodes are pattern matched against corresponding trees of values.

Nodes can be values, in which case a direct comparison is used, types, in which case an isinstance() check is performed, or callables, which will validate and optionally convert the value.

Public API


Schema.__init__(schema, required=False, extra=False)

Create a new Schema.

  • schema – Validation schema.
  • required – Keys defined in the schema must be in the data.
  • extra – Keys in the data need not have keys in the schema.



Validate data against self.schema. This simply is a shortcut for validate method.

Parameters:data – input data to validate
Returns:validated input
Raise :InvalidList


Schema.validate(path, schema, data)

Validate data against this schema.

  • path – (list) current path in the object, Starts as []
  • schema – schema to validate agains
  • data – input data to validate

validated input

Raise :


Project Versions

Table Of Contents

Previous topic


Next topic

Schema validators and markers

This Page