-
Notifications
You must be signed in to change notification settings - Fork 2
nested fields operations #67
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 extends ValidGen to support validation operations between nested struct fields, enabling comparisons like eqfield=Nested.Field2 in addition to existing inner field operations. The implementation updates the analyzer to resolve nested field paths, improves error reporting for type mismatches and undefined fields, and adds comprehensive test coverage for these scenarios.
- Enhances field operation analysis to handle both inner fields (
Field1) and nested fields (Nested.Field2) - Updates test naming convention to distinguish between "inner" and "nested" field operations
- Adds complete test suite for nested field validation scenarios
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
internal/analyzer/analyzer.go |
Core analyzer logic updated to resolve and validate nested field references with improved error messages |
tests/endtoend/cmp_between_nested_fields.go |
New comprehensive test file for nested field validation scenarios |
tests/endtoend/cmp_between_inner_fields.go |
Renamed and updated existing inner field tests for clarity |
tests/endtoend/validator__.go |
Generated validator functions for new nested field test cases |
tests/endtoend/main.go |
Updated test runner to include both inner and nested field test suites |
internal/analyzer/analyzer_test.go |
Expanded unit tests covering valid/invalid nested field operations |
internal/codegenerator/get_test_elements_between_fields_test.go |
Added test cases for nested field code generation |
internal/codegenerator/build_validator_test.go |
Updated with test cases for inner and nested field validation code |
internal/codegenerator/build_func_validator_test.go |
Added nested field operation test case |
internal/analyzer/parser_validation_test.go |
Added parser tests for inner and nested field validation syntax |
Closes #56
This PR extends the analyzer and code generator to support validation operations between nested struct fields (e.g.,
eqfield=Nested.Field2), not just top-level fields. It updates the analyzer logic to resolve and validate nested field references, improves error reporting for invalid or undefined nested fields, and adds comprehensive tests to cover these scenarios. Additionally, test names and code comments are updated for clarity regarding inner and nested field operations.Analyzer and Validation Logic Enhancements:
analyzeFieldOperationsininternal/analyzer/analyzer.goto resolve and validate operations between nested struct fields, improving error messages for mismatched types and undefined nested fields. [1] [2]Test Coverage Improvements:
internal/analyzer/analyzer_test.goto verify correct handling of valid and invalid operations between inner and nested fields, including mismatched types and undefined fields. [1] [2] [3]internal/analyzer/parser_validation_test.goto include cases for inner and nested field operations.Code Generation and Test Naming Updates:
internal/codegenerator/build_func_validator_test.goandinternal/codegenerator/build_validator_test.goto cover and assert correct code output for inner and nested field operations. [1] [2] [3]These changes significantly improve the analyzer's ability to handle complex validation scenarios involving nested structs and ensure robust test coverage for these cases.