Declarative validation for things that are not data models.
expectfs lets you define clear, readable expectations about files, directories,
and system state — without schemas, test frameworks, or boilerplate.
This is for validating the world, not validating Python objects.
pip install expectfsfrom expect import expect, validate
expect.file("metrics.json") \
.is_json() \
.size_gt(100)
result = validate()
result.print()If any expectation fails, a clear, actionable error message will be displayed after running validation.
Most validation tools focus on:
- JSON schemas
- Data models
- API payloads
- Function inputs
But engineers constantly need to validate things like:
- “Does this file exist?”
- “Is this directory populated?”
- “Is this JSON valid?”
- “Did my pipeline actually produce output?”
expectfs exists for that gap.
- Declarative, chainable expectations
- Automatic dependency resolution (rules run in the correct order)
- Rule caching (each rule runs at most once)
- Clear failure messages
expect.file("output.json").is_json().size_gt(1024)is_jsonautomatically ensures the file existssize_gtreuses prior results instead of re-running checks- Dependencies are resolved recursively
Users don’t need to think about ordering.
Currently supported:
- Files
- Directories
Planned:
- Globs
- Environment variables
- Command outputs
This project is in alpha.
- APIs may evolve
- Backwards compatibility is not yet guaranteed
- Feedback and contributions are welcome
MIT