PyPI
pypi.org โบ project โบ schema
schema ยท PyPI
schema is a library for validating Python data structures, such as those obtained from config-files, forms, external services or command-line parsing, converted from JSON/YAML (or something else) to Python data-types.
ยป pip install schema
Pydantic
docs.pydantic.dev โบ 1.10 โบ usage โบ schema
Schema - Pydantic
All sub-models' (and their sub-models') schemas are put directly in a top-level definitions JSON key for easy re-use and reference. "Sub-models" with modifications (via the Field class) like a custom title, description or default value, are recursively included instead of referenced. The description for models is taken from either the docstring of the class or the argument description to the Field class.
Videos
02:04
Learning About Schema and Data Types (Video) โ Real Python
13:45
JSON Schema Validation in Python: Bring Structure Into JSON - YouTube
49:27
MongoDB + Python #2 - Schema Validation, Advanced Queries and More ...
Kafka Tutorial | Confluent Kafka Schema Registry in Python | Schema ...
Kafka # 011 # Register the Schema in Schema Registry (Python)
jsonschema
python-jsonschema.readthedocs.io
jsonschema 4.26.0 documentation
PyPI version Supported Python versions Build status ReadTheDocs status pre-commit.ci status Zenodo DOI jsonschema is an implementation of the JSON Schema specification for Python. It can also be us...
Python-cerberus
docs.python-cerberus.org
Cerberus โ Data validation for Python
>>> schema = {'name': {'type': 'string'}} >>> v = Validator(schema)
Python-cerberus
docs.python-cerberus.org โบ schemas.html
Validation Schemas - Cerberus โ Data validation for Python
Cerberus schemas are built with vanilla Python types: dict, list, string, etc. Even user-defined validation rules are invoked in the schema by name as a string. A useful side effect of this design is that schemas can be defined in a number of ways, for example with PyYAML. >>> import yaml >>> schema_text = ''' ... name: ... type: string ... age: ... type: integer ... min: 10 ... ''' >>> schema = yaml.safe_load(schema_text) >>> document = {'name': 'Little Joe', 'age': 5} >>> v.validate(document, schema) False >>> v.errors {'age': ['min value is 10']}
GitHub
github.com โบ keleshev โบ schema
GitHub - keleshev/schema: Schema validation just got Pythonic ยท GitHub
This can be used to add word completion, validation, and documentation directly in code editors. The output schema can also be used with JSON schema compatible libraries. Just define your schema normally and call .json_schema() on it. The output is a Python dict, you need to dump it to JSON.
Starred by 2.9K users
Forked by 217 users
Languages ย Python
Polars
docs.pola.rs โบ api โบ python โบ dev โบ reference โบ schema โบ index.html
Schema โ Polars documentation
Ordered mapping of column names to their data type ยท The schema definition given by column names and their associated Polars data type. Accepts a mapping, or an iterable of tuples, or any object implementing the __arrow_c_schema__ PyCapsule interface (e.g. pyarrow schemas)
Horejsek
horejsek.github.io โบ python-fastjsonschema
Fast JSON schema for Python โ fastjsonschema documentation
Support only for Python 3.3 and higher. fastjsonschema implements validation of JSON documents by JSON schema. The library implements JSON schema drafts 04, 06, and 07. The main purpose is to have a really fast implementation.
Google Cloud
cloud.google.com โบ python โบ documentation โบ reference โบ class schema (0.13.12)
Class Schema (0.13.12) | Python client library | Google Cloud
Defines the structure and layout of a type of document data. This message has oneof_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time.
Pylonsproject
docs.pylonsproject.org โบ projects โบ colander โบ en โบ latest
colander 2.0 documentation - The Pylons Project
colander 2.0 documentation ยป ยท Colander ยท Colander is useful as a system for validating and deserializing data obtained via XML, JSON, an HTML form post or any other equally simple data serialization. It is tested on Python 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, and 3.10, and PyPy 2.7 and PyPy 3.8. Colander can be used to: Define a data schema.
Python-arango
docs.python-arango.com โบ en โบ main โบ schema.html
Schema Validation โ python-arango documentation
my_schema = { 'rule': { 'type': 'object', 'properties': { 'name': {'type': 'string'}, 'email': {'type': 'string'} }, 'required': ['name', 'email'] }, 'level': 'moderate', 'message': 'Schema Validation Failed.' } employees = db.create_collection(name='employees', schema=my_schema) # Modify the schema.
Towards Data Science
towardsdatascience.com โบ introduction-to-schema-a-python-libary-to-validate-your-data-c6d99e06d56a
Introduction to Schema: A Python Libary to Validate your ...
September 21, 2020 - We cannot provide a description for this page right now
Apache Arrow
arrow.apache.org โบ cookbook โบ py โบ schema.html
Working with Schema โ Apache Arrow Python Cookbook documentation
Arrow automatically infers the ... Python objects to Arrow objects. However, you might want to manually tell Arrow which data types to use, for example, to ensure interoperability with databases and data warehouse systems. This chapter includes recipes for dealing with schemas...
Top answer 1 of 10
76
You may use schema (PyPi Link)
schema is a library for validating Python data structures, such as those obtained from config-files, forms, external services or command-line parsing, converted from JSON/YAML (or something else) to Python data-types.
from schema import Schema, And, Use, Optional, SchemaError
def check(conf_schema, conf):
try:
conf_schema.validate(conf)
return True
except SchemaError:
return False
conf_schema = Schema({
'version': And(Use(int)),
'info': {
'conf_one': And(Use(float)),
'conf_two': And(Use(str)),
'conf_three': And(Use(bool)),
Optional('optional_conf'): And(Use(str))
}
})
conf = {
'version': 1,
'info': {
'conf_one': 2.5,
'conf_two': 'foo',
'conf_three': False,
'optional_conf': 'bar'
}
}
print(check(conf_schema, conf))
2 of 10
36
Use Pydantic!
Pydantic enforces type hints at runtime, and provides user friendly errors when data is invalid. Define how data should be in pure, canonical python; validate it with pydantic, as simple as that:
from pydantic import BaseModel
class Info(BaseModel):
conf_one: float
conf_two: str
conf_three: bool
class Config:
extra = 'forbid'
class ConfStructure(BaseModel):
version: int
info: Info
If validation fails pydantic will raise an error with a breakdown of what was wrong:
my_conf_wrong = {
'version': 1,
'info': {
'conf_one': 2.5,
'conf_two': 'foo',
'conf_three': False,
'optional_conf': 'bar'
}
}
my_conf_right = {
'version': 10,
'info': {
'conf_one': 14.5,
'conf_two': 'something',
'conf_three': False
}
}
model = ConfStructure(**my_conf_right)
print(model.dict())
# {'version': 10, 'info': {'conf_one': 14.5, 'conf_two': 'something', 'conf_three': False}}
res = ConfStructure(**my_conf_wrong)
# pydantic.error_wrappers.ValidationError: 1 validation error for ConfStructure
# info -> optional_conf
# extra fields not permitted (type=value_error.extra)
Readthedocs
python-jsonschema-objects.readthedocs.io โบ en โบ latest โบ Introduction.html
What โ Python JSONSchema Objects 0.0.18 documentation
Literal values are wrapped when constructed to support validation and other schema-related operations. However, you can still use them just as you would other literals. >>> import python_jsonschema_objects as pjs >>> builder = pjs.ObjectBuilder(examples['Example Schema']) >>> ns = builder.build_classes() >>> Person = ns.ExampleSchema >>> james = Person(firstName="James", lastName="Bond") >>> str(james.lastName) 'Bond' >>> james.lastName += "ing" >>> str(james.lastName) 'Bonding' >>> james.age = 4 >>> james.age - 1 3 >>> 3 + james.age 7 >>> james.lastName / 4 Traceback (most recent call last): ...
jsonschema
python-jsonschema.readthedocs.io โบ en โบ stable โบ validate
Schema Validation - jsonschema 4.26.0 documentation
The Basics: The simplest way to validate an instance under a given schema is to use the validate function. The Validator Protocol: jsonschema defines a protocol that all validator classes adhere to...
jsonschema
python-jsonschema.readthedocs.io โบ en โบ latest โบ validate
Schema Validation - jsonschema - Read the Docs
The Basics: The simplest way to validate an instance under a given schema is to use the validate function. The Validator Protocol: jsonschema defines a protocol that all validator classes adhere to...
GitHub
github.com โบ frictionlessdata โบ tableschema-py
GitHub - frictionlessdata/tableschema-py: A Python library for working with Table Schema. ยท GitHub
Starred by 266 users
Forked by 39 users
Languages ย Python 99.4% | Makefile 0.6%
Synapse
python-docs.synapse.org โบ en โบ stable โบ tutorials โบ python โบ json_schema
Working with JSON Schema - Synapse Python/Command Line Client Documentation
June 17, 2025 - JSON Schema is a tool used to validate data. In Synapse, JSON Schemas can be used to validate the metadata applied to an entity such as project, file, folder, table, or view, including the annotations applied to it. To learn more about JSON Schemas, check out JSON-Schema.org.