Skip to content

[6.x] Fail contains field conditions against an object instead of throwing - #15535

Merged
jasonvarga merged 2 commits into
statamic:6.xfrom
joshdaugherty:fix/field-conditions-contains-object
Sep 29, 2026
Merged

jasonvarga merged 2 commits into
statamic:6.xfrom
joshdaugherty:fix/field-conditions-contains-object

Conversation

@joshdaugherty

Copy link
Copy Markdown
Contributor

Fixes #15534

A contains or includes condition on a field whose value is a plain object, such as a date range ({ start, end }) or a group, threw TypeError: condition.lhs.includes is not a function. prepareLhs() passes objects through unchanged so that arrays keep includes(), and passesIncludesCondition() called includes() without checking it exists.

passesIncludesCondition() now fails the condition when the value can't be searched, which matches how passesCondition() already treats an object for every other operator (if (isObject(condition.lhs)) return false). Arrays and strings are unaffected, and under unless the failed condition still inverts as usual.

Tests

Adds it fails includes or contains conditions against an object instead of throwing to resources/js/tests/FieldConditionsValidator.test.js, with a date range and a group-like object under contains, includes and unless. On 6.x without the change it throws TypeError: condition.lhs.includes is not a function; with it, it passes. The file's other 52 tests still pass, and npx vitest run --project unit passes (628 tests).

@joshdaugherty joshdaugherty changed the title Fail contains field conditions against an object instead of throwing [6.x] Fail contains field conditions against an object instead of throwing Sep 29, 2026
@jasonvarga
jasonvarga merged commit 864cc2f into statamic:6.x Sep 29, 2026
61 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.

contains field condition throws a TypeError when the field value is an object

2 participants