Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

add JSON node should match context - #234

Merged
sanpii merged 3 commits into
Behatch:masterfrom
badaz:sg-feat-node-should-match
Dec 19, 2017
Merged

add JSON node should match context#234
sanpii merged 3 commits into
Behatch:masterfrom
badaz:sg-feat-node-should-match

Conversation

@badaz

@badaz badaz commented Dec 19, 2017

Copy link
Copy Markdown
Contributor

Hi,

First, thanks for your work. I was looking for a way to check that a json node matched a pattern and only found the "JSON should be valid according to this schema" way which seemed a little overkill when you only want to test one JSON node. So this should be used to test a single node against a regex.

@sanpii sanpii left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also update i18n/en.xliff.dist file?

Comment thread src/Context/JsonContext.php Outdated

$actual = $this->inspector->evaluate($json, $node);

if (!((bool) preg_match($pattern, $actual))) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless cast, simply test:

if (preg_match(…) === 0)

@badaz

badaz commented Dec 19, 2017

Copy link
Copy Markdown
Contributor Author

Done

@sanpii
sanpii merged commit 3f7038a into Behatch:master Dec 19, 2017
@sanpii

sanpii commented Dec 19, 2017

Copy link
Copy Markdown
Member

Merged, thank you 😃

@sanpii sanpii added this to the 3.1 milestone Dec 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants