gookit / validate

⚔ Go package for data validation and filtering. support Map, Struct, Form data. Go通用的数据验证与过滤库,使用简单,内置大部分常用验证、过滤器,支持自定义验证器、自定义消息、字段翻译。
https://gookit.github.io/validate/
MIT License
1.08k stars 116 forks source link

Fix for Boolean Pointer Field Validation Error #240

Closed kaptinlin closed 1 year ago

kaptinlin commented 1 year ago

Problem:

Issue #239 highlighted a validation error that occurs with structs containing boolean pointer fields. When a boolean value is assigned to these fields, an erroneous error message is generated, stating that a boolean value must be provided.

Changes:

In this pull request, we have addressed this issue by refining the validation logic to correctly process boolean pointer fields. This ensures that assigned boolean values, including false, are appropriately validated without generating incorrect error messages.

Verification:

The implemented fix has been verified with various scenarios to ensure the validation error is resolved, and the validation process works as intended.

Additional Context:

This enhancement ensures that validation is consistent and accurate when dealing with boolean pointer fields, providing reliable outcomes for all future validations.

coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 7033770324


Changes Missing Coverage Covered Lines Changed/Added Lines %
util.go 19 20 95.0%
<!-- Total: 36 37 97.3% -->
Totals Coverage Status
Change from base Build 6541589985: 0.1%
Covered Lines: 2878
Relevant Lines: 2992

💛 - Coveralls
kaptinlin commented 1 year ago

These commits addresses the issue reported in #248 by enhancing the gookit/validate package's ability to handle and validate pointer variables. Previously, validations on pointers, especially for primitive types like strings and integers, did not correctly dereference the pointers to validate the underlying values. This update introduces changes to enable direct validation of pointer variable values.

Key Improvements:

  1. Pointer Support: The validation logic has been expanded to include proper handling and dereferencing of pointer variables. This allows for direct validation of the values pointed to by these variables.

  2. Comprehensive Testing: New test cases have been added to cover the validation of pointer variables. These tests ensure that both string and integer pointers are correctly validated, maintaining the robustness of the package.

  3. Maintaining Code Integrity: Care has been taken to ensure that these changes are consistent with the existing coding standards and practices within the gookit/validate package.

By introducing these enhancements, the package now offers more flexible validation options, catering to a broader range of use cases involving pointer variables. The implementation ensures that validations are correctly performed on the actual values, thus improving the reliability and functionality of the package.

I welcome any feedback or suggestions on this pull request.