From e490a4aeb7b87292979ed07fc33dc401a3be7818 Mon Sep 17 00:00:00 2001 From: Tyler Akins Date: Wed, 7 Nov 2012 20:45:15 -0600 Subject: [PATCH] Patterns don't start with '/' according to the mailing list --- src/Json/Validator.php | 4 ++-- tests/mock/pattern.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Json/Validator.php b/src/Json/Validator.php index b9b249d..2b44cd6 100644 --- a/src/Json/Validator.php +++ b/src/Json/Validator.php @@ -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)); } } @@ -756,4 +756,4 @@ protected function checkDivisibleBy($entity, $schema, $entityName) return $this; } -} \ No newline at end of file +} diff --git a/tests/mock/pattern.json b/tests/mock/pattern.json index 81a65a0..ff0cede 100644 --- a/tests/mock/pattern.json +++ b/tests/mock/pattern.json @@ -1,4 +1,4 @@ { "type" : "string", - "pattern" : "/^[A-Z]+$/" -} \ No newline at end of file + "pattern" : "^[A-Z]+$" +}