Skip to content

Conversation

@alexgarzao
Copy link
Collaborator

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:

  • Updated analyzeFieldOperations in internal/analyzer/analyzer.go to resolve and validate operations between nested struct fields, improving error messages for mismatched types and undefined nested fields. [1] [2]
  • Improved error messages for invalid operations, mismatched types, and undefined (nested) fields in validation logic.

Test Coverage Improvements:

  • Added new tests in internal/analyzer/analyzer_test.go to verify correct handling of valid and invalid operations between inner and nested fields, including mismatched types and undefined fields. [1] [2] [3]
  • Expanded parser validation tests in internal/analyzer/parser_validation_test.go to include cases for inner and nested field operations.

Code Generation and Test Naming Updates:

  • Enhanced code generation tests in internal/codegenerator/build_func_validator_test.go and internal/codegenerator/build_validator_test.go to cover and assert correct code output for inner and nested field operations. [1] [2] [3]
  • Updated test names and comments throughout test files to clarify the distinction between inner and nested field operations, improving readability and maintainability. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

These changes significantly improve the analyzer's ability to handle complex validation scenarios involving nested structs and ensure robust test coverage for these cases.

@alexgarzao alexgarzao requested a review from Copilot August 30, 2025 21:41
@alexgarzao alexgarzao self-assigned this Aug 30, 2025
Copy link
Contributor

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 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

@alexgarzao alexgarzao merged commit d479d31 into main Sep 1, 2025
4 checks passed
@alexgarzao alexgarzao deleted the 56-operation-nested-fields branch September 1, 2025 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deal with operations between fields in nested structs

5 participants