Skip to content

Conversation

@alexgarzao
Copy link
Collaborator

Closes #77

This PR adds support for float types (float32 and float64) 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:

  • Added <FLOAT> as a valid type for all relevant operations (e.g., eq, required, gt, gte, lt, lte, min, neq, in, nin) in internal/analyzer/operations.go, enabling validation rules for float fields. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Code generation enhancements:

  • Updated internal/codegenerator/condition_table.go to 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:

  • Expanded unit tests in internal/analyzer/operations_test.go to verify float support for all operations, and added new tests in internal/codegenerator/get_test_elements_numeric_test.go specifically for float fields. [1] [2] [3] [4] [5] [6] [7]
  • Added code generation tests for float fields in internal/codegenerator/build_validator_test.go.

Helper function updates:

  • Modified internal/common/helpers.go to map normalized float types to their Go equivalents for basic, map, slice, and array forms. [1] [2] [3] [4]

Miscellaneous:

  • Updated the Makefile to handle float-based generated test files for end-to-end testing.
  • Renamed a test function for clarity in get_test_elements_numeric_test.go.

@alexgarzao alexgarzao requested a review from Copilot October 9, 2025 17:57
@alexgarzao alexgarzao self-assigned this Oct 9, 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 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

@alexgarzao alexgarzao merged commit 0c462a0 into main Oct 10, 2025
4 checks passed
@alexgarzao alexgarzao deleted the 77-support-float-types branch October 10, 2025 21:43
@alexgarzao alexgarzao restored the 77-support-float-types branch October 10, 2025 21:47
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.

Implement support for float types

3 participants