Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Json/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ protected function checkExclusiveMaximum($entity, $schema, $entityName)
protected function checkPattern($entity, $schema, $entityName)
{
if (isset($schema->pattern) && $schema->pattern) {
if (!preg_match($schema->pattern, $entity)) {
if (!preg_match('/' . $schema->pattern . '/', $entity)) {
throw new ValidationException(sprintf('String does not match pattern for [%s]', $entityName));
}
}
Expand Down Expand Up @@ -756,4 +756,4 @@ protected function checkDivisibleBy($entity, $schema, $entityName)

return $this;
}
}
}
4 changes: 2 additions & 2 deletions tests/mock/pattern.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"type" : "string",
"pattern" : "/^[A-Z]+$/"
}
"pattern" : "^[A-Z]+$"
}