Skip to content

fix: validation when key does not exists#10006

Open
michalsn wants to merge 3 commits intocodeigniter4:developfrom
michalsn:fix/validation-key-not-exists
Open

fix: validation when key does not exists#10006
michalsn wants to merge 3 commits intocodeigniter4:developfrom
michalsn:fix/validation-key-not-exists

Conversation

@michalsn
Copy link
Member

@michalsn michalsn commented Feb 25, 2026

Description
Fixes a bug where wildcard field validation (e.g., contacts.friends.*.name) silently skipped array elements that were missing the validated key whenever at least one sibling element had it present. Only the elements whose key existed in the data were validated. The rest were invisible to all rules.

The root cause is that the validator builds $values by filtering a flattened array - keys absent from the data simply never appear, so there is nothing to validate against. For non-wildcard fields, this is not a problem because
dot_array_search() already returns null for a missing key. Wildcard fields had no equivalent treatment.

Fixes #8006

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@michalsn michalsn added the bug Verified issues on the current code behavior or pull requests that will fix them label Feb 25, 2026
@michalsn michalsn marked this pull request as draft February 25, 2026 19:04
@michalsn michalsn marked this pull request as ready for review February 25, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Validation passes if key does not exist when using asterisk

1 participant