-
Notifications
You must be signed in to change notification settings - Fork 4
add regex argument to string()
& nullOrString()
#59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add regex argument to string()
& nullOrString()
#59
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #59 +/- ##
============================================
+ Coverage 93.86% 93.88% +0.02%
- Complexity 459 461 +2
============================================
Files 72 72
Lines 1614 1620 +6
============================================
+ Hits 1515 1521 +6
Misses 99 99 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Once PHPStan is green. LGTM 👍 |
} | ||
|
||
if (null !== $regex) { | ||
Assert::stringNotEmpty($regex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use trimmed non empty string here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
if (null !== $regex) { | ||
Assert::stringNotEmpty($regex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Description
This PR adds an optional
$regex
parameter to the methods:ValueObjectTrait::nullOrString
&ValueObjectTrait::string
.Changes:
string
method now accepts an optional?string $regex
parameter.regex
is set, the value is validated against the given regex.\InvalidArgumentException
is thrown when regex is empty or the value not matches the expression.Motivation:
StoryBlok provides an regex validation for string fields.