-
-
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
[RFC] Pattern expanders #21
Comments
Yes this is interesting. I am thinking how to implement the repeat format with was mentioned in other issue like:
Something similar to chancancode/json_expressions#18 |
Oh I forgot about repeat expander. But above implementation require custom JSON parser. I think that using following syntax would be much easier:
Exapnder definition: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In most cases patterns are enough to create our expectations against value but sometimes there is a need to check something more. For example if we want to check if integer is lower than X or if array contain specific key/value.
Of course there is a expression pattern which is very elastic but it also make our patterns big, less readable and sometimes hard to understand.
I believe it would be nice to expand patterns with some extra critierias.
Few examples:
Following patterns will match
['foo' => 'bar']
value@[email protected]('foo':'bar')
@[email protected]('foo')
@[email protected]('bar')
Following patterns will match "25" value:
@[email protected](23)
@[email protected](20)
@[email protected](10, 100)
Following patterns will match
"Hello world"
value:@[email protected]('Hello')
@[email protected]('World')
@[email protected]('llo Wo')
I think there might be a need to use more than one expander for a pattern.
@[email protected]('Hello').contains(' ').endWith('World')
First matcher will check if pattern match value and after that value is going to be check against every single expander. The result will be positive only if every single expander return "true".
Maybe there are some more expanders we can add?
The text was updated successfully, but these errors were encountered: