cfgv
cfgv is a Python library designed to validate configuration files and produce human-readable error messages. The current version is 3.5.0, and it follows a regular release cadence with updates and improvements.
Warnings
- breaking In version 3.5.0, the validate function now raises a ValidationError instead of returning a boolean value. Ensure your code handles this exception appropriately.
- gotcha When defining schemas, ensure that all required fields are included to prevent validation errors. Missing fields can lead to unexpected behavior.
Install
-
pip install cfgv
Imports
- cfgv
import cfgv
Quickstart
import cfgv
# Define your configuration schema
schema = {
'host': str,
'port': int,
'debug': bool
}
# Load your configuration
config = {
'host': 'localhost',
'port': 8080,
'debug': True
}
# Validate the configuration
cfgv.validate(config, schema)