Install & Compatibility
Where this runs
tested against v6.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.164s · 21.8MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 1.9s · import 0.138s · 23MB
20MB installed
● package 20MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
yamale
✓ import yamale
Main library import for schema and data handling.
make_schema
✓ yamale.make_schema('./schema.yaml')
Used to load and parse a schema file.
make_data
✓ yamale.make_data('./data.yaml')
Used to load and parse a data file for validation.
validate
✓ yamale.validate(schema, data)
The primary function to validate data against a schema. Throws ValueError on invalid data.
This quickstart demonstrates how to define a simple YAML schema and then validate a YAML data file against it using Yamale's API. It creates temporary schema and data files, performs validation, and prints the result.
import yamale
import os
# Create dummy schema.yaml and data.yaml files for demonstration
# In a real scenario, these would be pre-existing files.
with open('schema.yaml', 'w') as f:
f.write('name: str()\nage: int(max=200)\nawesome: bool()')
with open('data.yaml', 'w') as f:
f.write('name: Bill\nage: 26\nawesome: True')
try:
# Import Yamale and make a schema object:
schema = yamale.make_schema('./schema.yaml')
# Create a Data object
data = yamale.make_data('./data.yaml')
# Validate data against the schema. Throws a ValueError if data is invalid.
yamale.validate(schema, data)
print('Validation success! Data is valid against the schema.')
except ValueError as e:
print(f'Validation failed!\n{e}')
except FileNotFoundError as e:
print(f'Error: {e}. Ensure schema.yaml and data.yaml exist.')
finally:
# Clean up dummy files
if os.path.exists('schema.yaml'):
os.remove('schema.yaml')
if os.path.exists('data.yaml'):
os.remove('data.yaml')
yamale --version
Debug
Known issues
breakingIn version 6.0.0, the command-line interface (CLI) was updated to strictly enforce that all paths provided to CLI arguments must exist. Previously, non-existent paths might have been silently ignored or handled differently.fixEnsure all file and directory paths passed to the `yamale` CLI command are valid and exist before execution.
affects: >=6.0.0
breakingVersion 5.0.0 dropped support for Python versions older than 3.8. Running Yamale on Python 3.7 or earlier will result in errors.fixUpgrade your Python environment to version 3.8 or newer to use Yamale v5.0.0 and above. The latest release supports Python 3.8+ up to 3.14.
affects: >=5.0.0
gotchaYamale schemas should always originate from trusted sources. The library does not inherently protect against intentionally malicious schemas, which could potentially lead to arbitrary code execution if an attacker controls the schema file. (A specific code injection vulnerability, CVE-2021-38305, was addressed in v3.0.8).fixOnly use schema files from known, trusted sources. Never use schemas provided by untrusted users directly. If schemas must be user-provided, implement strict sanitization and validation on the schema content itself before passing it to Yamale.
affects: <3.0.8 (for CVE), All versions (general principle)
gotchaBy default, Yamale operates in 'strict' mode. This means that if the data being validated contains elements (keys in a map, or items in a list) that are not explicitly defined in the schema, validation will fail. This can be unexpected if you want to allow extra data.fixTo allow extra, unspecified elements in your data without causing validation errors, you can disable strict mode. Use the `--no-strict` flag with the CLI or pass `strict=False` to the `yamale.validate()` function when using the API. You can also apply strict mode selectively to includes.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'yamale'
The `yamale` library is not installed in the current Python environment.
FileNotFoundError: [Errno 2] No such file or directory:
The specified schema or data YAML file does not exist at the given path, or the path is incorrect.
fixVerify the file path and name, ensuring they are correct and the file exists relative to where the script is run.
Yamale says: field 'id' (from 'root') is required
The data YAML file is missing a field that is marked as required in the schema.
fixAdd the missing field to the data YAML, or update the schema to mark the field as optional (e.g., `id: int(required=False)` or `id: int()?`).
Yamale says: 'name': 'John Doe' is not a valid integer
A field in the data YAML file does not match the expected data type defined in the Yamale schema.
fixEnsure the data in the YAML file conforms to the type specified in the schema (e.g., `name: 123` if schema expects `int()`), or adjust the schema to match the data.
Yamale says: Unknown validator 'mycustomvalidator' found.
The schema uses a validator (either built-in or custom) that is not recognized by Yamale, often due to a typo or an unregistered custom validator.
fixCheck for typos in built-in validator names or ensure custom validators are properly defined and passed to `yamale.validate` using the `validators` argument.
Upgrade
Version history
6.1.0latest on PyPI · released Nov 20, 2025
Audit
Dependencies
PyYAMLrequiredCore dependency for YAML parsing.
ruamel.yamloptionalOptional dependency for YAML 1.2 support, recommended for modern YAML usage.