|
5 | 5 | * To re-generate this file run `make test` |
6 | 6 | * |
7 | 7 | * |
8 | | - * @generated SignedSource<<731edaf71398ea5fb65cfa1e09cab571>> |
| 8 | + * @generated SignedSource<<458640baae767319d7594d9b4fcce940>> |
9 | 9 | */ |
10 | 10 | namespace Slack\Hack\JsonSchema\Tests\Generated; |
11 | 11 | use namespace Slack\Hack\JsonSchema; |
12 | 12 | use namespace Slack\Hack\JsonSchema\Constraints; |
13 | 13 |
|
| 14 | +type TArraySchemaValidatorPropertiesUnsupportedUniqueItemsItems = shape( |
| 15 | + ?'foo' => string, |
| 16 | + ... |
| 17 | +); |
| 18 | + |
14 | 19 | type TArraySchemaValidator = shape( |
15 | 20 | ?'array_of_strings' => vec<string>, |
16 | 21 | ?'untyped_array' => vec<mixed>, |
17 | 22 | ?'coerce_array' => vec<num>, |
18 | 23 | ?'unique_strings' => keyset<string>, |
19 | 24 | ?'unique_numbers' => keyset<int>, |
20 | 25 | ?'unique_numbers_coerce' => keyset<int>, |
| 26 | + ?'unsupported_unique_items' => vec<TArraySchemaValidatorPropertiesUnsupportedUniqueItemsItems>, |
21 | 27 | ... |
22 | 28 | ); |
23 | 29 |
|
@@ -252,6 +258,88 @@ public static function check(mixed $input, string $pointer): keyset<int> { |
252 | 258 | } |
253 | 259 | } |
254 | 260 |
|
| 261 | +final class ArraySchemaValidatorPropertiesUnsupportedUniqueItemsItemsPropertiesFoo { |
| 262 | + |
| 263 | + private static bool $coerce = false; |
| 264 | + |
| 265 | + public static function check(mixed $input, string $pointer): string { |
| 266 | + $typed = Constraints\StringConstraint::check($input, $pointer, self::$coerce); |
| 267 | + |
| 268 | + return $typed; |
| 269 | + } |
| 270 | +} |
| 271 | + |
| 272 | +final class ArraySchemaValidatorPropertiesUnsupportedUniqueItemsItems { |
| 273 | + |
| 274 | + private static bool $coerce = false; |
| 275 | + |
| 276 | + public static function check( |
| 277 | + mixed $input, |
| 278 | + string $pointer, |
| 279 | + ): TArraySchemaValidatorPropertiesUnsupportedUniqueItemsItems { |
| 280 | + $typed = Constraints\ObjectConstraint::check($input, $pointer, self::$coerce); |
| 281 | + |
| 282 | + $errors = vec[]; |
| 283 | + $output = shape(); |
| 284 | + |
| 285 | + /*HHAST_IGNORE_ERROR[UnusedVariable] Some loops generated with this statement do not use their $value*/ |
| 286 | + foreach ($typed as $key => $value) { |
| 287 | + /* HH_IGNORE_ERROR[4051] allow dynamic access to preserve input. See comment in the codegen lib for reasoning and alternatives if needed. */ |
| 288 | + $output[$key] = $value; |
| 289 | + } |
| 290 | + |
| 291 | + if (\HH\Lib\C\contains_key($typed, 'foo')) { |
| 292 | + try { |
| 293 | + $output['foo'] = ArraySchemaValidatorPropertiesUnsupportedUniqueItemsItemsPropertiesFoo::check( |
| 294 | + $typed['foo'], |
| 295 | + JsonSchema\get_pointer($pointer, 'foo'), |
| 296 | + ); |
| 297 | + } catch (JsonSchema\InvalidFieldException $e) { |
| 298 | + $errors = \HH\Lib\Vec\concat($errors, $e->errors); |
| 299 | + } |
| 300 | + } |
| 301 | + |
| 302 | + if (\HH\Lib\C\count($errors)) { |
| 303 | + throw new JsonSchema\InvalidFieldException($pointer, $errors); |
| 304 | + } |
| 305 | + |
| 306 | + /* HH_IGNORE_ERROR[4163] */ |
| 307 | + return $output; |
| 308 | + } |
| 309 | +} |
| 310 | + |
| 311 | +final class ArraySchemaValidatorPropertiesUnsupportedUniqueItems { |
| 312 | + |
| 313 | + private static bool $coerce = false; |
| 314 | + |
| 315 | + public static function check( |
| 316 | + mixed $input, |
| 317 | + string $pointer, |
| 318 | + ): vec<TArraySchemaValidatorPropertiesUnsupportedUniqueItemsItems> { |
| 319 | + $typed = Constraints\ArrayConstraint::check($input, $pointer, self::$coerce); |
| 320 | + |
| 321 | + $output = vec[]; |
| 322 | + $errors = vec[]; |
| 323 | + |
| 324 | + foreach ($typed as $index => $value) { |
| 325 | + try { |
| 326 | + $output[] = ArraySchemaValidatorPropertiesUnsupportedUniqueItemsItems::check( |
| 327 | + $value, |
| 328 | + JsonSchema\get_pointer($pointer, (string) $index), |
| 329 | + ); |
| 330 | + } catch (JsonSchema\InvalidFieldException $e) { |
| 331 | + $errors = \HH\Lib\Vec\concat($errors, $e->errors); |
| 332 | + } |
| 333 | + } |
| 334 | + |
| 335 | + if (\HH\Lib\C\count($errors)) { |
| 336 | + throw new JsonSchema\InvalidFieldException($pointer, $errors); |
| 337 | + } |
| 338 | + |
| 339 | + return $output; |
| 340 | + } |
| 341 | +} |
| 342 | + |
255 | 343 | final class ArraySchemaValidator |
256 | 344 | extends JsonSchema\BaseValidator<TArraySchemaValidator> { |
257 | 345 |
|
@@ -338,6 +426,17 @@ public static function check( |
338 | 426 | } |
339 | 427 | } |
340 | 428 |
|
| 429 | + if (\HH\Lib\C\contains_key($typed, 'unsupported_unique_items')) { |
| 430 | + try { |
| 431 | + $output['unsupported_unique_items'] = ArraySchemaValidatorPropertiesUnsupportedUniqueItems::check( |
| 432 | + $typed['unsupported_unique_items'], |
| 433 | + JsonSchema\get_pointer($pointer, 'unsupported_unique_items'), |
| 434 | + ); |
| 435 | + } catch (JsonSchema\InvalidFieldException $e) { |
| 436 | + $errors = \HH\Lib\Vec\concat($errors, $e->errors); |
| 437 | + } |
| 438 | + } |
| 439 | + |
341 | 440 | if (\HH\Lib\C\count($errors)) { |
342 | 441 | throw new JsonSchema\InvalidFieldException($pointer, $errors); |
343 | 442 | } |
|
0 commit comments