coduo/php-matcher

Confusing error message

alexsegura opened this issue ยท 3 comments

Hi.

Thank you for making PHP Matcher ๐Ÿ™‚

With a PHP Matcher expectation like this:

{
  "@context":"/api/contexts/ConstraintViolationList",
  "@type":"ConstraintViolationList",
  "hydra:title":"An error occurred",
  "hydra:description":@string@,
  "violations":[
    {
      "propertyPath":"total",
      "message":@string@,
      "code":""
    }
  ]
}

If [violations][0][code] is null null, PHP Matcher gives the following message

Value "" does not match pattern "" at path: "[violations][0][code]"

This is confusing, when seeing this you wonder why "" !== "" ๐Ÿค”


Maybe it could be instead:

Value null does not match pattern "" at path: "[violations][0][code]"

could you please create an example https://php-matcher.norbert.tech/ and share the URL here so I can replicate this issue?

@alexsegura I was just wondering why haven't used @null@ as in the documentation?

If you do so as for the other kind of validations, the error will be more clear: LIKE HERE