[#15491] Fix allowEmpty value-list array support in AbstractValidator and Alpha empty-value handling#16904
Merged
niden merged 5 commits intophalcon:5.0.xfrom Apr 23, 2026
Merged
Conversation
…alidator; fixing alpha validation
Jeckerson
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello!
In raising this pull request, I confirm the following:
Small description of change:
#15491 —
AbstractValidator::allowEmpty()value-list array supportAbstractValidator::allowEmpty()previously treated every array value of theallowEmptyoption as a per-field map (['fieldName' => true/false]). This meant that the common patternallowEmpty => [null, ''](a list of values that should be skipped) silently fell back tofalsefor all field names, so validation was never skipped.The method now checks both forms:
['fieldName' => true]) — checked first viaisset $allowEmpty[$field], preserving the existing behaviour used by theIpvalidator.[null, '']) — falls through to a strict===loop, consistent withValidation::preChecking(), so'0'is never silently treated as empty.Three new
Forms\Form\IsValidTesttests confirm thatForm::isValid()correctly uses the stored entity (from the constructor or frombind()) and thatallowEmpty=[null,'']skips validation for null/empty values from a bound entity with a null property.#16200 —
Alphasilently passes empty string whenallowEmpty = falsepreg_match("/[^[:alpha:]]/imu", "")returns 0 (no non-alpha chars in an empty string), soAlphaincorrectly returnedtruefor empty/null values even whenallowEmptywas explicitly set tofalse.Alpha::validate()now adds an explicit guard: if the cast value is an empty string andgetOption("allowEmpty") === false(explicitly set, not the default), it appends a message and returnsfalse. WhenallowEmptyis not set the previous behaviour is preserved.Thanks