Skip to content
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

[WIP] Match expander #35 #101

Closed
wants to merge 3 commits into from
Closed

Conversation

partikus
Copy link
Contributor

Still in progress.

@partikus
Copy link
Contributor Author

partikus commented Jul 22, 2017

Match expander does not work with TextMatcher and JsonMatcher yet.
Replacement @json@ with regex converter under TextMatcher needs bigger effort.

Problem only occurs for cases when JSON pattern has multilines:

WRONG:

$value = <<<TXT
{
    "users": [
        {
            "url": "https://google.com"
        }
    ]
}
TXT;

$pattern = '{
    "users": @[email protected](
        {
            "url": "@[email protected]()"
        }
    )
}';

OK:

$value = <<<TXT
{
    "users": [
        {
            "name": "Johny Deep"
        }
    ]
}
TXT;

$pattern = json_encode([
    "users" => sprintf("@[email protected](%s)", json_encode([
        "name" => '@string@'
    ]))
]);

I tried to change TextMatcher::PATTERN_REGEXP by adding line break chars etc but no success

@norberttech
Copy link
Member

Thanks for your work, let me review that next week (busy weekend) and I will back to you with some feedback

@norberttech norberttech added this to the 3.0.0 milestone Aug 12, 2017
@shakaran
Copy link

shakaran commented Sep 9, 2017

@norzechowicz any progress checking and reviewing this PR?

@norberttech
Copy link
Member

hey @partikus any chance you could rebase this one? I know it's old, if you don't have time I can do it.
I just found another valid use case for JsonObjectMatcher and match expander.

#133

This PR would allow to do something similar to:

{
  "image": "@[email protected](optional(), match(...))"
}

or

{
  "image": "@json@optional()||@json.match(...))"
}

(I think both should work fine)

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.

3 participants