Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.10' ]
python-version: [ '3.9', '3.10', '3.11', '3.12' ]

steps:
- uses: actions/checkout@v4
Expand All @@ -20,9 +20,11 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install coverage
run: |
pip install coverage
pip install .
- name: Run tests with coverage
run: |
coverage run --source=valideer setup.py test
coverage run --source=valideer -m unittest discover -s valideer/tests
coverage report -m > coverage.txt # Save the report to a file
cat coverage.txt # Display the report in the log
65 changes: 65 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

Valideer is a lightweight Python data validation and adaptation library that provides:
- **Validation**: Check if values conform to defined schemas
- **Adaptation**: Convert valid input to appropriate output formats
- **Declarative schemas**: Mini-language for defining validation rules
- **Extensibility**: Custom validators and adaptors

## Development Commands

```bash
# Run tests
python setup.py test

# Run tests with coverage via tox
tox

# Install in development mode
python setup.py install

# Run tests with coverage (CI approach)
coverage run --source=valideer setup.py test
coverage report
```

## Code Architecture

### Core Components

- **`valideer/base.py`** - Core validation framework containing:
- `Validator` base class and validation infrastructure
- `ValidationError` and `SchemaError` exception classes
- Function decorators: `@accepts`, `@returns`, `@adapts`
- Schema parsing and error formatting

- **`valideer/validators.py`** - Built-in validator implementations:
- Primitive validators: `Boolean`, `Integer`, `Number`, `String`
- Collection validators: `Mapping`, `Sequence`, `Set`
- Temporal validators: `Date`, `Time`, `Datetime`
- Composite validators: `AnyOf`, `AllOf`, `ChainOf`, `Nullable`, `Range`

- **`valideer/compat.py`** - Python 3 compatibility utilities

### Key Patterns

- **Validator Registration**: Validators auto-register using `Validator.__init_subclass__`
- **Schema Parsing**: String schemas are parsed into validator instances via `parse()`
- **Error Context**: Validation errors include path context showing where validation failed
- **Adaptation Pattern**: Validators can both validate and transform data

### Testing

- **Framework**: Python unittest (single test file with 171 tests)
- **Coverage**: Comprehensive test coverage across all validators
- **Test Structure**: One large test file organized by validator type

## Dependencies

- **Runtime**: `decorator` package for function decoration
- **Development**: `coverage` for test coverage reporting
- **Python Version**: 3.10 (recently migrated)
Loading