From c112d67f237a9fa79ea75cdf577c8d2ece1a52eb Mon Sep 17 00:00:00 2001 From: Laurent Wiesel Date: Wed, 11 Feb 2015 10:37:46 +0100 Subject: [PATCH] Do not throw errors when using unknown format --- src/JsonSchema/Constraints/FormatConstraint.php | 2 +- tests/JsonSchema/Tests/Constraints/FormatTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/JsonSchema/Constraints/FormatConstraint.php b/src/JsonSchema/Constraints/FormatConstraint.php index d939f962..8f6fba2f 100644 --- a/src/JsonSchema/Constraints/FormatConstraint.php +++ b/src/JsonSchema/Constraints/FormatConstraint.php @@ -112,7 +112,7 @@ public function check($element, $schema = null, $path = null, $i = null) break; default: - $this->addError($path, "Unknown format: " . json_encode($schema->format)); + // Do nothing so that custom formats can be used. break; } } diff --git a/tests/JsonSchema/Tests/Constraints/FormatTest.php b/tests/JsonSchema/Tests/Constraints/FormatTest.php index f5d8d18e..e10bb76b 100644 --- a/tests/JsonSchema/Tests/Constraints/FormatTest.php +++ b/tests/JsonSchema/Tests/Constraints/FormatTest.php @@ -118,6 +118,8 @@ public function getValidFormats() array('::ff', 'ipv6'), array('www.example.com', 'host-name'), + + array('anything', '*'), ); } @@ -158,8 +160,6 @@ public function getInvalidFormats() array(':::ff', 'ipv6'), array('localhost', 'host-name'), - - array('anything', '*'), ); }