-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
Added UUID pattern support for the TextMatcher #130
Added UUID pattern support for the TextMatcher #130
Conversation
90ea224
to
7ff9063
Compare
7ff9063
to
86df2d3
Compare
@@ -21,6 +21,8 @@ public function toRegex(TypePattern $typePattern) : string | |||
return '(\\-?[0-9]*)'; | |||
case 'double': | |||
return '(\\-?[0-9]*[\\.|\\,][0-9]*)'; | |||
case 'uuid': | |||
return "([\da-f]{8}-[\da-f]{4}-[1-5][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12})"; |
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.
I think we already have this pattern somewhere, maybe in UuidMatcher? Could you try to reuse it without duplicatuin?
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.
Yes of course, the pattern const in the UuidMatcher
includes the start / end position :
'|^[\da-f]{8}-[\da-f]{4}-[1-5][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$|';
So it's ok for this update in the UuidMatcher
?
const UUID_PATTERN = '[\da-f]{8}-[\da-f]{4}-[1-5][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}';
const MATCH_PATTERN = '/^'.self::UUID_PATTERN.'$/';
We will can reuse the UUID_PATTERN
const in the RegexConverter
.
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.
actually to avoid BC break we would need to have 3 consts. Those 2 that you mentioned (with different names) above and 1 with not changed name builded from those 2.
However I don't believe anybody would use this pattern anywhere outside php-matcher, but still it's better to be safe then sorry
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.
I pushed a new commit with these two constants :
const UUID_PATTERN = '[\da-f]{8}-[\da-f]{4}-[1-5][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}';
const UUID_FORMAT_PATTERN = '|^'.self::UUID_PATTERN.'$|';
Thanks 👍 |
This PR resolves the #112 issue. It enables to use the
@uuid@
pattern with theTextMatcher
.This pattern is actually not supported :
Type pattern "@uuid@" is not supported by TextMatcher.
After this patch, we can use :