Merged
Conversation
asadijabar
previously approved these changes
Feb 25, 2026
There was a problem hiding this comment.
Pull request overview
This PR introduces an opt-in typed transformer stage to Rigging's configuration loading pipeline. The transformer feature allows users to canonicalize or derive typed configuration values after binding/defaults/type conversion but before tag-based validation runs. This addresses a real need where users previously had to mutate config inside validators, which was semantically unclear and ran too late for tag validation constraints.
Changes:
- Added
Transformer[T]interface andTransformerFunc[T]adapter with execution logic in the load pipeline - Added comprehensive test coverage for transformer registration and pre-validation execution
- Added documentation in API reference, README, runnable example, and GoDoc example
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| loader.go | Adds Transformer interface, TransformerFunc adapter, WithTransformer method, and transformer execution in loadInternal between binding and tag validation |
| loader_test.go | Adds tests for transformer initialization, registration, and pre-validation execution order |
| examples/transformer/main.go | New runnable example demonstrating environment variable canonicalization before oneof validation |
| example_test.go | Adds ExampleLoader_WithTransformer GoDoc example |
| examples/basic/main.go | Refactored to extract helper functions into separate files (no functional change) |
| examples/basic/config.go | Extracted config types and validator from main.go |
| examples/basic/output.go | Extracted output formatting functions from main.go |
| examples/README.md | Added transformer example to the index |
| docs/api-reference.md | Documents Transformer interface, TransformerFunc, and updated load pipeline description |
| README.md | Updated "Policy-Driven Validation" section to mention transformers and added transformer example |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fca3ee5 to
2c20562
Compare
asadijabar
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add an opt-in typed transformer stage to Rigging's load pipeline, plus docs and examples for the new API.
This PR is scoped to the transformer feature only (and its direct tests/docs/examples), specifically:
Transformer[T],TransformerFunc[T], andLoader.WithTransformer(...)inloader.goLoader.loadInternalloader_test.goExampleLoader_WithTransformerinexample_test.goexamples/transformer/main.goand index it inexamples/README.mddocs/api-reference.mdWhy
Users often need to canonicalize typed config values (trim/lowercase/derive fields) before tag validation runs.
Without a dedicated stage, the only workaround is mutating inside
WithValidator(...), which is:oneof,min/max, etc.)This feature provides a clear, explicit hook for typed value transforms while preserving:
requiredsemantics (tracked during binding)Type
Testing
Executed and verified:
gofmt -w loader.go loader_test.go gofmt -w example_test.go gofmt -w examples/transformer/main.go go test ./...Result:
go test ./...passed (including compile checks forexamples/transformer)Would run (not executed in this change set):
Checklist
go test ./...)gofmt -s -w .)go vet ./...)Notes:
gofmt -w(not repo-widegofmt -s -w .)For reviewers: Does this align with Rigging's philosophy of simplicity and zero dependencies?