Skip to content

Commit e490a4a

Browse files
committed
Patterns don't start with '/' according to the mailing list
1 parent 62b2bb9 commit e490a4a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Json/Validator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ protected function checkExclusiveMaximum($entity, $schema, $entityName)
500500
protected function checkPattern($entity, $schema, $entityName)
501501
{
502502
if (isset($schema->pattern) && $schema->pattern) {
503-
if (!preg_match($schema->pattern, $entity)) {
503+
if (!preg_match('/' . $schema->pattern . '/', $entity)) {
504504
throw new ValidationException(sprintf('String does not match pattern for [%s]', $entityName));
505505
}
506506
}
@@ -756,4 +756,4 @@ protected function checkDivisibleBy($entity, $schema, $entityName)
756756

757757
return $this;
758758
}
759-
}
759+
}

tests/mock/pattern.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"type" : "string",
3-
"pattern" : "/^[A-Z]+$/"
4-
}
3+
"pattern" : "^[A-Z]+$"
4+
}

0 commit comments

Comments
 (0)