| @@ 87-100 (lines=14) @@ | ||
| 84 | * |
|
| 85 | * @return \League\JsonGuard\ValidationError|null |
|
| 86 | */ |
|
| 87 | private static function validateRegex($format, $value, $pattern, $errorCode, $pointer) |
|
| 88 | { |
|
| 89 | if (!is_string($value) || preg_match($pattern, $value) === 1) { |
|
| 90 | return null; |
|
| 91 | } |
|
| 92 | ||
| 93 | return new ValidationError( |
|
| 94 | 'Value {value} does not match the format {format}', |
|
| 95 | $errorCode, |
|
| 96 | $value, |
|
| 97 | $pointer, |
|
| 98 | ['value' => $value, 'format' => $format] |
|
| 99 | ); |
|
| 100 | } |
|
| 101 | ||
| 102 | /** |
|
| 103 | * @param string $format |
|
| @@ 76-89 (lines=14) @@ | ||
| 73 | * |
|
| 74 | * @return \League\JsonGuard\ValidationError|null |
|
| 75 | */ |
|
| 76 | private static function validateType($value, $type, callable $callable, $errorCode, $pointer) |
|
| 77 | { |
|
| 78 | if (call_user_func($callable, $value) === true) { |
|
| 79 | return null; |
|
| 80 | } |
|
| 81 | ||
| 82 | return new ValidationError( |
|
| 83 | 'Value {value} is not a(n) {type}', |
|
| 84 | $errorCode, |
|
| 85 | $value, |
|
| 86 | $pointer, |
|
| 87 | ['value' => $value, 'type' => $type] |
|
| 88 | ); |
|
| 89 | } |
|
| 90 | ||
| 91 | /** |
|
| 92 | * @param mixed $value |
|