|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a .NET Standard library for recursive DataAnnotations validation, extending the built-in validation capabilities to handle nested objects and collections within objects. |
| 8 | + |
| 9 | +The core functionality is provided by `RecursiveDataAnnotationValidator` which: |
| 10 | +- Validates an object graph recursively, traversing nested properties |
| 11 | +- Prevents infinite loops in cyclical object references |
| 12 | +- Supports `IEnumerable` collections for recursive validation |
| 13 | +- Allows skipping specific properties with `[SkipRecursiveValidation]` attribute |
| 14 | + |
| 15 | +## Project Structure |
| 16 | + |
| 17 | +The codebase has a clear separation between the main library and tests: |
| 18 | + |
| 19 | +1. **src/RecursiveDataAnnotationsValidation/** - The core library project with: |
| 20 | + - Main validator implementation (`RecursiveDataAnnotationValidator.cs`) |
| 21 | + - Skip attribute for excluding properties from validation (`SkipRecursiveValidation.cs`) |
| 22 | + - Extension methods and interfaces |
| 23 | + |
| 24 | +2. **test/RecursiveDataAnnotationsValidation.Tests/** - Test project with: |
| 25 | + - Tests for various recursive validation scenarios |
| 26 | + - Example test models (RecursionExample, EnumerableExample, etc.) |
| 27 | + |
| 28 | +3. **examples/** - Example project showing usage patterns |
| 29 | + |
| 30 | +## Commands for Development |
| 31 | + |
| 32 | +### Build |
| 33 | +```bash |
| 34 | +dotnet build src/RecursiveDataAnnotationsValidation/RecursiveDataAnnotationsValidation.csproj |
| 35 | +``` |
| 36 | + |
| 37 | +### Run Tests |
| 38 | +```bash |
| 39 | +dotnet test test/RecursiveDataAnnotationsValidation.Tests/RecursiveDataAnnotationsValidation.Tests.csproj |
| 40 | +``` |
| 41 | + |
| 42 | +### Run Single Test |
| 43 | +```bash |
| 44 | +dotnet test test/RecursiveDataAnnotationsValidation.Tests/RecursiveDataAnnotationsValidation.Tests.csproj --filter "RecursionExampleTests.Passes_all_validation" |
| 45 | +``` |
| 46 | + |
| 47 | +### Run Tests with Coverage |
| 48 | +```bash |
| 49 | +dotnet test test/RecursiveDataAnnotationsValidation.Tests/RecursiveDataAnnotationsValidation.Tests.csproj --collect:"XPlat Code Coverage" |
| 50 | +``` |
| 51 | + |
| 52 | +## Key Files to Understand |
| 53 | + |
| 54 | +- `RecursiveDataAnnotationValidator.cs` - Main implementation that handles recursive object validation |
| 55 | +- `SkipRecursiveValidationAttribute.cs` - Attribute for excluding properties from recursive validation |
| 56 | +- Test models in `test/RecursiveDataAnnotationsValidation.Tests/TestModels/` show various usage patterns |
| 57 | + |
| 58 | +## Target Frameworks |
| 59 | + |
| 60 | +- Main library targets `.NET Standard 2.0` |
| 61 | +- Test project targets `net8.0` |
| 62 | + |
| 63 | +## Development Notes |
| 64 | + |
| 65 | +The recursive validator handles: |
| 66 | +1. Cyclical object references to prevent infinite loops |
| 67 | +2. Collections (IEnumerable) with recursive validation of items |
| 68 | +3. Null value handling for nested objects and collections |
| 69 | +4. Proper error message formatting that includes property paths |
| 70 | + |
| 71 | +The validator uses reflection to examine object properties and recursively validate nested objects. |
0 commit comments