Polars-based data validation library with an extensible OOP validator architecture.
- Extensible: create custom parsers and checks by inheriting from base classes
- Type-safe: generic validator classes with runtime validation
- Discoverable: tag-based validator discovery and registration
- Flexible: add, remove, or reorder validation phases
- Validated: strict dependency enforcement prevents invalid configurations
- Observable: built-in logging and metrics collection
- Intuitive:
schema.validate(df, registry), the schema owns validation - Pythonic: clean, object-oriented design
- Out-of-core: built on Polars
LazyFrame, designed for larger-than-RAM data
pip install nyctea
# or with uv
uv add nyctea
import polars as pl
from nyctea import Registry, SchemaModel, register_builtins
# Define schema
schema = SchemaModel.from_dict({
"columns": {
"name": {
"dtype": "Utf8",
"parsers": [{"name": "strip"}, {"name": "lower"}],
"nullable": False,
},
"age": {
"dtype": "Int64",
"parsers": [{"name": "to_int"}],
"checks": [{"name": "min_value", "args": {"min": 0}}],
"nullable": False,
},
}
})
# Register built-in validators
registry = Registry()
register_builtins(registry)
# Load and validate data
df = pl.scan_csv("data.csv")
result = schema.validate(df, registry)
# Inspect results
print(result.report.summary())
print(result.data.collect())
import polars as pl
from nyctea.validators import ColumnParser, ValidatorMetadata
class TrimParser(ColumnParser):
def __init__(self):
super().__init__(ValidatorMetadata(
name="trim",
description="Remove whitespace",
tags=["string", "cleaning"],
))
def execute(self, column: pl.Expr, **kwargs) -> pl.Expr:
return column.str.strip_chars()
def validate_args(self, **kwargs) -> None:
pass # No arguments
registry.register_column_parser(TrimParser())
import polars as pl
from nyctea import checker, frame_checker, frame_parser, parser
@checker(registry=registry, name="positive", tags=["numeric"])
def is_positive(column: pl.Expr) -> pl.Expr:
return column > 0
Validator[TInput, TOutput]
├── ColumnValidator[pl.Expr, pl.Expr]
│ ├── ColumnParser (transformations)
│ └── ColumnCheck (validations)
└── FrameValidator[pl.LazyFrame, pl.LazyFrame]
├── FrameParser (transformations)
└── FrameCheck (validations)
Registry
├── column_parsers: ValidatorRegistry[ColumnParser]
├── column_checks: ValidatorRegistry[ColumnCheck]
├── frame_parsers: ValidatorRegistry[FrameParser]
└── frame_checks: ValidatorRegistry[FrameCheck]
ValidationPipeline
├── ColumnResolutionPhase (synonyms)
├── ColumnParsingPhase (transformations)
├── CoercionPhase (dtype coercion)
└── ColumnCheckPhase (checks, nullable enforcement)
uv run pytest tests/ -v
uv run pytest tests/ --cov=src/nyctea --cov-report=term --cov-report=html
uv run ruff check src/ tests/
uv run ty check src/nyctea
CI runs linting, type checking, and the test suite on Python 3.11 through 3.14 for every pull request.
- Quickstart: getting started guide
- Features: schema syntax and validator capabilities
- Registry guide: registering and discovering validators
- API reference: full public API
- Breaking changes: migrating between versions
Contributions are welcome. Open an issue before starting anything beyond a trivial fix; see docs/development/contributing.md for the full workflow (issue-first, branch and PR conventions, CI overview) and DEVELOPMENT.md for local setup.
MIT
