-
Notifications
You must be signed in to change notification settings - Fork 2
support float types (#77) #89
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 adds comprehensive support for float types (float32 and float64) to the ValidGen validation framework, extending the tool's capabilities to handle floating-point number validation alongside existing string, boolean, and integer types.
Key Changes
- Added
<FLOAT>type support to all relevant validation operations in analyzer and code generation components - Implemented complete test coverage for float validation scenarios including unit, integration, and end-to-end tests
- Restructured numeric test organization by separating integer and float tests into distinct files and functions
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/analyzer/operations.go | Added <FLOAT> type support to validation operations (eq, required, gt, gte, lt, lte, neq, in, nin) |
| internal/codegenerator/condition_table.go | Implemented float-specific code generation templates for all supported validation operations |
| internal/common/types.go | Added float32/float64 to Go type recognition and normalization mapping |
| internal/common/helpers.go | Extended helper functions to map <FLOAT> to concrete float types for basic, map, slice, and array forms |
| tests/endtoend/numeric_float.go | New comprehensive end-to-end tests for float32 and float64 validation scenarios |
| tests/endtoend/numeric_int.go | Renamed and refactored to focus specifically on integer type testing |
| tests/endtoend/main.go | Updated to call separate integer and float test functions |
| internal/codegenerator/get_test_elements_numeric_test.go | Added dedicated test suite for float field validation and renamed existing integer tests |
| Multiple test files | Added comprehensive unit and integration test coverage for float type support |
Closes #77
This PR adds support for float types (
float32andfloat64) to the validation framework, ensuring that all relevant validation operations can be performed on float fields alongside existing types. The changes cover analyzer logic, code generation, test coverage, and helper functions to fully integrate float handling.Validation logic and analyzer updates:
<FLOAT>as a valid type for all relevant operations (e.g.,eq,required,gt,gte,lt,lte,min,neq,in,nin) ininternal/analyzer/operations.go, enabling validation rules for float fields. [1] [2] [3] [4] [5] [6] [7] [8] [9]Code generation enhancements:
internal/codegenerator/condition_table.goto generate correct Go validation code for float fields across all supported operations, including error messages and logical operators for set operations. [1] [2] [3] [4] [5] [6] [7] [8] [9]Test coverage improvements:
internal/analyzer/operations_test.goto verify float support for all operations, and added new tests ininternal/codegenerator/get_test_elements_numeric_test.gospecifically for float fields. [1] [2] [3] [4] [5] [6] [7]internal/codegenerator/build_validator_test.go.Helper function updates:
internal/common/helpers.goto map normalized float types to their Go equivalents for basic, map, slice, and array forms. [1] [2] [3] [4]Miscellaneous:
get_test_elements_numeric_test.go.