1 | <?php |
||
9 | class Format implements PropertyConstraint |
||
10 | { |
||
11 | // regex from http://www.pelagodesign.com/blog/2009/05/20/iso-8601-date-validation-that-doesnt-suck/ |
||
12 | // @codingStandardsIgnoreStart |
||
13 | const DATE_TIME_PATTERN = '/^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/'; |
||
14 | // @codingStandardsIgnoreEnd |
||
15 | |||
16 | const HOST_NAME_PATTERN = '/^[_a-z]+\.([_a-z]+\.?)+$/i'; |
||
17 | |||
18 | /** |
||
19 | * {@inheritdoc} |
||
20 | */ |
||
21 | 2 | public static function validate($value, $parameter, $pointer = null) |
|
78 | |||
79 | /** |
||
80 | * @param string $format |
||
81 | * @param mixed $value |
||
82 | * @param string $pattern |
||
83 | * @param int $errorCode |
||
84 | * @param string $pointer |
||
85 | * |
||
86 | * @return \League\JsonGuard\ValidationError|null |
||
87 | */ |
||
88 | 2 | private static function validateRegex($format, $value, $pattern, $errorCode, $pointer) |
|
96 | |||
97 | /** |
||
98 | * @param string $format |
||
99 | * @param mixed $value |
||
100 | * @param int $filter |
||
101 | * @param mixed $options |
||
102 | * @param int $errorCode |
||
103 | * @param string $pointer |
||
104 | * |
||
105 | * @return \League\JsonGuard\ValidationError|null |
||
106 | */ |
||
107 | 2 | private static function validateFilter($format, $value, $filter, $options, $errorCode, $pointer) |
|
115 | |||
116 | /** |
||
117 | * @param string $format |
||
118 | * @param mixed $value |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | 2 | private static function invalidFormatMessage($format, $value) |
|
126 | } |
||
127 |