src/JsonEncoder.php 1 location
|
@@ 133-139 (lines=7) @@
|
130 |
|
*/ |
131 |
|
public function encode($data, $schema = null) |
132 |
|
{ |
133 |
|
if (null !== $schema) { |
134 |
|
$errors = $this->validator->validate($data, $schema); |
135 |
|
|
136 |
|
if (count($errors) > 0) { |
137 |
|
throw ValidationFailedException::fromErrors($errors); |
138 |
|
} |
139 |
|
} |
140 |
|
|
141 |
|
$options = 0; |
142 |
|
|
src/JsonDecoder.php 1 location
|
@@ 111-117 (lines=7) @@
|
108 |
|
|
109 |
|
$decoded = $this->decodeJson($json); |
110 |
|
|
111 |
|
if (null !== $schema) { |
112 |
|
$errors = $this->validator->validate($decoded, $schema); |
113 |
|
|
114 |
|
if (count($errors) > 0) { |
115 |
|
throw ValidationFailedException::fromErrors($errors); |
116 |
|
} |
117 |
|
} |
118 |
|
|
119 |
|
return $decoded; |
120 |
|
} |