-
Notifications
You must be signed in to change notification settings - Fork 2
move tag parser to analyzer stage #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 refactors the validation system to use strongly-typed *Validation objects instead of string representations throughout the analyzer and code generator components. The change improves type safety by moving validation parsing from the code generation stage to the analyzer stage, ensuring validation errors are caught earlier in the process.
Key changes:
- Updated
FieldValidations.Validationsfrom[]stringto[]*Validationin the analyzer - Modified all code generator functions to accept
*Validationobjects instead of strings - Added comprehensive test utilities and updated all test cases to use the new typed approach
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/analyzer/struct.go | Changed FieldValidations.Validations field type from []string to []*Validation |
| internal/analyzer/analyzer.go | Added validation parsing logic to AnalyzeStructs function with error handling |
| internal/codegenerator/build_validator.go | Updated function signatures to accept *Validation objects |
| internal/codegenerator/test_elements.go | Refactored DefineTestElements to work with *Validation objects directly |
| internal/codegenerator/utils_test.go | Added AssertParserValidation helper function for tests |
| internal/codegenerator/utils.go | Minor formatting change (added blank line) |
| internal/codegenerator/*_test.go | Updated all test files to use the new AssertParserValidation helper |
| Makefile | Enhanced with comprehensive 'all' target and improved organization |
Closes #62
This PR refactors the way field validations are represented and processed across the analyzer and code generator components. Instead of using strings to represent validations, the code now uses strongly-typed
*Validationobjects. This change improves type safety, error handling, and clarity throughout the codebase. The update also touches all relevant tests and utility functions to work with the new representation.Core refactoring to use typed validations:
FieldValidations.Validationsfield from[]stringto[]*Validationininternal/analyzer/struct.go, and updated all related code to use*Validationobjects instead of strings. [1] [2]AnalyzeStructsto parse validations into*Validationobjects and propagate errors using a custom error type.build_validator.goandtest_elements.go) to accept and process*Validationobjects, including updating function signatures and validation handling logic. [1] [2] [3] [4] [5]Test and utility updates:
AssertParserValidationhelper, which parses validation strings into*Validationobjects, ensuring consistency and type safety in test code. [1] [2] [3] [4] [5] [6] [7] [8] [9]AssertParserValidationhelper function toutils.gofor use in tests, streamlining validation parsing and error handling in test cases. [1] [2]Error handling improvements:
Build and infrastructure:
Makefileto define a comprehensivealltarget that runs clean, tests, builds, and benchmarks, and consolidated.PHONYdeclarations.These changes collectively modernize the validation handling in the codebase, making it more robust and maintainable.