Skip to content

Child validator refactoring#29

Merged
feO2x merged 9 commits intomainfrom
28-child-validator-refactoring
Mar 22, 2026
Merged

Child validator refactoring#29
feO2x merged 9 commits intomainfrom
28-child-validator-refactoring

Conversation

@feO2x
Copy link
Copy Markdown
Owner

@feO2x feO2x commented Mar 22, 2026

This pull request completes and documents the child-validation and collection-validation refactoring for the validation package, ensuring a consistent, robust, and easy-to-use API for both synchronous and asynchronous validation scenarios. It introduces new helpers for child context creation, improves collection validation semantics, and updates documentation and usage examples to reflect the new design.

Validation API and Implementation Improvements:

  • Added explicit child-scope helpers to Check<T> to preserve target ownership and normalization state, preventing duplicate path segments in nested validation.
  • Refactored collection validation to require explicit null guarding, removed automatic null-error creation, and clarified supported collection shapes for normalization and transformation.
  • Introduced delegate-based item validation overloads for primitive and ad-hoc scenarios, and extended support for transforming item validators on arrays, List<T>, and ImmutableArray<T>.
  • Added async parity for child and collection validation, including ValidateChildAsync and ValidateItemsAsync with ValueTask and CancellationToken support [1] [2] [3] [4] [5].

Documentation and Example Updates:

  • Expanded the README.md with a comprehensive "Validation Quick Start" section, including code samples for both synchronous and asynchronous validation flows, and clarified collection validation best practices [1] [2].
  • Updated XML documentation in AsyncValidator.cs for improved clarity and to reflect new method semantics [1] [2] [3].

Project and Benchmark Adjustments:

  • Added a new plan document (0028-child-validation-refactoring.md) to track the completion criteria, technical details, and rationale for the refactoring [1] [2].
  • Updated benchmark code to use the new validation APIs, simplifying child validation calls and aligning with the new API surface [1] [2].

Minor Edits and Cleanups:

  • Improved phrasing and clarity in agent and documentation files.
  • Removed unused usings in BaseValidator.cs.

These changes collectively make the validation package more consistent, extensible, and easier to use, especially in complex nested and asynchronous scenarios.

@feO2x feO2x self-assigned this Mar 22, 2026
@feO2x feO2x added the enhancement New feature or request label Mar 22, 2026
@feO2x feO2x linked an issue Mar 22, 2026 that may be closed by this pull request
10 tasks
@feO2x feO2x requested a review from Copilot March 22, 2026 07:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the child-validation and collection-validation refactor in Light.PortableResults.Validation, introducing explicit child-scope helpers on Check<T> and a unified fluent API for sync/async nested and collection validation, with updated docs/tests/benchmarks to match.

Changes:

  • Added Check<T> child-context helpers and new CheckExtensions APIs (ValidateChild*, ValidateItems*) with sync/async parity.
  • Refactored collection validation semantics to require explicit null-guarding (throw on null unless short-circuited) and added delegate-based + transforming overloads.
  • Updated validators, tests, benchmarks, and README/documentation to reflect the new API and semantics.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/Light.PortableResults.Validation.Tests/ValidatorTests.cs Updates existing tests to the new fluent child/item validation APIs and result semantics.
tests/Light.PortableResults.Validation.Tests/CheckExtensionsTests.cs Adds extensive coverage for child/context target ownership, collection semantics, delegate-based item validation, transformations, and async parity.
src/Light.PortableResults.Validation/Validator.cs Switches root validation to use the new child-validation pipeline entry (ValidateChildValue) and makes it public with docs.
src/Light.PortableResults.Validation/ValidatedValue.cs Adjusts nullability annotations for TryGetValue.
src/Light.PortableResults.Validation/CheckExtensions.cs Introduces the new fluent child and collection validation extension methods (sync/async, validator/delegate, transforming overloads).
src/Light.PortableResults.Validation/Check.cs Adds child-context creation helpers and refines target normalization/composition behavior.
src/Light.PortableResults.Validation/BaseValidator.cs Removes legacy child-validation helper methods in favor of CheckExtensions.
src/Light.PortableResults.Validation/AsyncValidator.cs Aligns async validation pipeline with the new child-validation entry and updates XML docs.
benchmarks/Benchmarks/ValidationEndpointBenchmarks.cs Updates benchmark code to compile and use the new child-validation API surface.
ai-plans/0028-child-validation-refactoring.md Adds the completion plan/acceptance criteria and design notes for the refactor.
README.md Adds a “Validation Quick Start” section and updates examples to the new patterns (null-guarding, items/child, async).
Light.PortableResults.slnx Includes the new plan document in solution items.
AGENTS.md Minor phrasing update.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Light.PortableResults.Validation/Validator.cs Outdated
Comment thread src/Light.PortableResults.Validation/Validator.cs Outdated
Comment thread src/Light.PortableResults.Validation/CheckExtensions.cs Outdated
Comment thread src/Light.PortableResults.Validation/CheckExtensions.cs Outdated
Comment thread tests/Light.PortableResults.Validation.Tests/CheckExtensionsTests.cs Outdated
@github-actions
Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Complexity Health
Light.PortableResults 96% 94% 2300
Light.PortableResults.AspNetCore.MinimalApis 93% 80% 25
Light.PortableResults.AspNetCore.Mvc 93% 80% 26
Light.PortableResults.AspNetCore.Shared 94% 92% 28
Light.PortableResults.Validation 73% 56% 811
Summary 90% (4513 / 5001) 85% (2192 / 2587) 3190

Minimum allowed line rate is 60%

@feO2x feO2x merged commit 9a113d1 into main Mar 22, 2026
2 checks passed
@feO2x feO2x deleted the 28-child-validator-refactoring branch March 22, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Child Validation Refactoring

2 participants