Skip to content

Conversation

@debba
Copy link
Contributor

@debba debba commented Aug 22, 2025

What kind of change does this PR introduce? (pls check at least one)

  • [x ] Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe below

Description

I really appreciate the Leafs project and its simplicity.
I fixed a small bug in the validation system.
Basically, these types of checks always fail.

$validatedData = $validator->validate(['booleankey' => false], ['booleankey' => 'boolean']);

The validator incorrectly treated false as a missing value, causing boolean validation to fail when the input was explicitly set to false.

Changes:

Updated the "required" check to only consider null, empty strings, and empty arrays as missing values.

Adjusted boolean handling so that false is properly converted to "0" before regex checks.

false is now recognized as a valid boolean value.

No impact on other validation rules or falsy values like 0 and "0".

  - Fix optional field validation to properly handle null, empty string, and empty array
  - Add explicit boolean value conversion to string for validation
  - Improve missing value detection with strict type checking
@debba debba changed the title fix: improve validation logic for optional fields and boolean handling fix: improve validation logic for boolean fields Aug 22, 2025
@mychidarko
Copy link
Member

Thanks for the PR @debba

@mychidarko mychidarko merged commit fbbd495 into leafsphp:v3.x Sep 10, 2025
15 checks passed
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.

2 participants