public function match($value, $pattern)
{
if (parent::match($value, $pattern)) {
return true;
}
if (!Json::isValid($value)) {
$this->error = sprintf("Invalid given JSON of value. %s", $this->getErrorMessage());
return false;
}
if (!Json::isValidPattern($pattern)) {
$this->error = sprintf("Invalid given JSON of pattern. %s", $this->getErrorMessage());
return false;
}
$transformedPattern = Json::transformPattern($pattern);
$match = $this->matcher->match(json_decode($value, true), json_decode($transformedPattern, true));
if (!$match) {
$this->error = $this->matcher->getError();
return false;
}
return true;
}