Skip to content

[RFC] Pattern expanders  #21

@norberttech

Description

@norberttech

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions