You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: enhance numeric coerce() to handle empty strings
Enhanced coercion behavior for better form data handling:
## IntValidator & FloatValidator Changes:
- Empty strings ('') now coerce to 0 and 0.0 respectively
- Maintains backward compatibility for existing numeric coercion
- Addresses real-world HTML form scenarios where empty fields are common
## Test Coverage Added:
- 6 new tests across IntValidatorTest.php and FloatValidatorTest.php
- Tests cover empty string coercion, numeric strings, and error cases
- All tests pass (15 tests, 51 assertions)
## Roadmap Updates:
- Removed redundant emptyToZero() method from roadmap
- Added Enhanced coerce() as completed feature
- Updated examples to show cleaner API usage
## Real-World Impact:
Before: Validator::isInt()->coerce()->validate('') // ❌ ValidationException
After: Validator::isInt()->coerce()->validate('') // ✅ Returns 0
This makes form validation significantly more practical and intuitive.
0 commit comments