From 4ac3d2cec3eed98ebc27946c772ffda799c71a70 Mon Sep 17 00:00:00 2001 From: kekko1212 Date: Mon, 16 Jan 2017 11:03:12 +0000 Subject: [PATCH] Fix regex for Rfc3339 validation --- src/JsonSchema/Rfc3339.php | 2 +- tests/Constraints/FormatTest.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/JsonSchema/Rfc3339.php b/src/JsonSchema/Rfc3339.php index 5afdaed4..62509aa5 100644 --- a/src/JsonSchema/Rfc3339.php +++ b/src/JsonSchema/Rfc3339.php @@ -4,7 +4,7 @@ class Rfc3339 { - const REGEX = '/(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))/'; + const REGEX = '/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/'; /** * Try creating a DateTime instance diff --git a/tests/Constraints/FormatTest.php b/tests/Constraints/FormatTest.php index 6e386b2f..c09decd9 100644 --- a/tests/Constraints/FormatTest.php +++ b/tests/Constraints/FormatTest.php @@ -150,6 +150,9 @@ public function getInvalidFormats() array('00:00:60', 'time'), array('25:00:00', 'time'), + + array('invalid_value_2000-05-01T12:12:12Z', 'date-time'), + array('2000-05-01T12:12:12Z_invalid_value', 'date-time'), array('1999-1-11T00:00:00Z', 'date-time'), array('1999-01-11T00:00:00+100', 'date-time'), array('1999-01-11T00:00:00+1:00', 'date-time'),