Skip to content

Feat: Contains validator#9

Merged
Meldiron merged 6 commits into
mainfrom
feat-contains-validator
May 14, 2026
Merged

Feat: Contains validator#9
Meldiron merged 6 commits into
mainfrom
feat-contains-validator

Conversation

@Meldiron
Copy link
Copy Markdown
Contributor

No description provided.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 14, 2026

Greptile Summary

This PR introduces a new Contains validator that checks whether a string contains at least one of the predefined substrings, with optional case-insensitive matching via mb_strtolower and UTF-8 encoding.

  • Adds src/Validator/Contains.php with constructor validation (empty-pattern guard), non-strict/strict matching, and proper Unicode handling using mb_strtolower('UTF-8').
  • Adds tests/Validator/ContainsTest.php with thorough coverage: single/multiple patterns, strict/loose modes, Unicode, multilines, empty strings, and non-string values.

Confidence Score: 4/5

The core validation logic is correct and the test suite is thorough, but unresolved issues flagged in prior review threads about non-string pattern elements causing unhandled TypeErrors should be addressed before merging.

The new Contains validator is well-structured: it correctly guards against non-string values, uses mb_strtolower with explicit UTF-8 encoding, and is backed by comprehensive tests. The outstanding concern raised in prior threads — that non-string elements inside the $patterns array trigger an unhandled TypeError in both isValid() and getDescription() — remains unaddressed in this revision.

src/Validator/Contains.php — specifically the constructor, which does not validate that all elements of $patterns are strings.

Important Files Changed

Filename Overview
src/Validator/Contains.php New Contains validator — solid implementation with correct UTF-8 handling; non-string elements inside $patterns still cause an unhandled TypeError (noted in prior review threads).
tests/Validator/ContainsTest.php Comprehensive test coverage across strict/loose modes, Unicode, multiline, empty patterns, and non-string values.

Reviews (3): Last reviewed commit: "Merge branch 'feat-contains-validator' o..." | Re-trigger Greptile

Comment thread src/Validator/Contains.php Outdated
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Comment thread src/Validator/Contains.php
Copy link
Copy Markdown
Contributor Author

@Meldiron Meldiron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Meldiron Meldiron merged commit 9770269 into main May 14, 2026
4 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.

1 participant