@@ 36-50 (lines=15) @@ | ||
33 | * |
|
34 | * @return \League\JsonGuard\ValidationError|null |
|
35 | */ |
|
36 | public static function validateMax($value, $parameter, $pointer) |
|
37 | { |
|
38 | if (!is_numeric($value) || |
|
39 | JsonGuard\compare($value, $parameter) === -1 || JsonGuard\compare($value, $parameter) === 0) { |
|
40 | return null; |
|
41 | } |
|
42 | ||
43 | return new ValidationError( |
|
44 | 'Value {value} is not at most {max}', |
|
45 | self::KEYWORD, |
|
46 | $value, |
|
47 | $pointer, |
|
48 | ['value' => $value, 'max' => $parameter] |
|
49 | ); |
|
50 | } |
|
51 | ||
52 | /** |
|
53 | * @param mixed $value |
|
@@ 59-72 (lines=14) @@ | ||
56 | * |
|
57 | * @return \League\JsonGuard\ValidationError|null |
|
58 | */ |
|
59 | public static function validateExclusiveMax($value, $parameter, $pointer) |
|
60 | { |
|
61 | if (!is_numeric($value) || JsonGuard\compare($value, $parameter) === -1) { |
|
62 | return null; |
|
63 | } |
|
64 | ||
65 | return new ValidationError( |
|
66 | 'Value {value} is not less than {exclusive_max}', |
|
67 | self::EXCLUSIVE_KEYWORD, |
|
68 | $value, |
|
69 | $pointer, |
|
70 | ['value' => $value, 'exclusive_max' => $parameter] |
|
71 | ); |
|
72 | } |
|
73 | } |
|
74 |
@@ 59-72 (lines=14) @@ | ||
56 | * |
|
57 | * @return \League\JsonGuard\ValidationError|null |
|
58 | */ |
|
59 | public static function validateExclusiveMin($value, $parameter, $pointer = null) |
|
60 | { |
|
61 | if (!is_numeric($value) || JsonGuard\compare($value, $parameter) === 1) { |
|
62 | return null; |
|
63 | } |
|
64 | ||
65 | return new ValidationError( |
|
66 | 'Number {value} is not at least greater than {exclusive_min}', |
|
67 | self::EXCLUSIVE_KEYWORD, |
|
68 | $value, |
|
69 | $pointer, |
|
70 | ['value' => $value, 'exclusive_min' => $parameter] |
|
71 | ); |
|
72 | } |
|
73 | } |
|
74 |