|
5 | 5 | * To re-generate this file run `make test` |
6 | 6 | * |
7 | 7 | * |
8 | | - * @generated SignedSource<<766d50148a61a631dcd0c430fed23430>> |
| 8 | + * @generated SignedSource<<fd534ebd94b67fe23410f2616abaa107>> |
9 | 9 | */ |
10 | 10 | namespace Slack\Hack\JsonSchema\Tests\Generated; |
11 | 11 | use namespace Slack\Hack\JsonSchema; |
|
16 | 16 | type TObjectSchemaValidatorPropertiesOnlyNoAdditionalProperties = dict<string, mixed>; |
17 | 17 |
|
18 | 18 | type TObjectSchemaValidatorPropertiesOnlyProperties = shape( |
19 | | - ?'string' => string, |
20 | | - ?'number' => num, |
| 19 | + 'string' => string, |
| 20 | + 'number' => num, |
| 21 | + 'required_string' => string, |
| 22 | +); |
| 23 | + |
| 24 | +type TObjectSchemaValidatorPropertiesDefaults = shape( |
21 | 25 | 'required_string' => string, |
| 26 | + 'default_string' => string, |
22 | 27 | ); |
23 | 28 |
|
24 | 29 | type TObjectSchemaValidatorPropertiesOnlyPatternProperties = dict<string, mixed>; |
|
88 | 93 | ?'only_additional_properties' => TObjectSchemaValidatorPropertiesOnlyAdditionalProperties, |
89 | 94 | ?'only_no_additional_properties' => TObjectSchemaValidatorPropertiesOnlyNoAdditionalProperties, |
90 | 95 | ?'only_properties' => TObjectSchemaValidatorPropertiesOnlyProperties, |
| 96 | + ?'defaults' => TObjectSchemaValidatorPropertiesDefaults, |
91 | 97 | ?'only_pattern_properties' => TObjectSchemaValidatorPropertiesOnlyPatternProperties, |
92 | 98 | ?'single_pattern_property_string' => TObjectSchemaValidatorPropertiesSinglePatternPropertyString, |
93 | 99 | ?'single_pattern_property_object' => TObjectSchemaValidatorPropertiesSinglePatternPropertyObject, |
@@ -276,6 +282,106 @@ public static function check( |
276 | 282 | } |
277 | 283 | } |
278 | 284 |
|
| 285 | +final class ObjectSchemaValidatorPropertiesDefaultsPropertiesRequiredString { |
| 286 | + |
| 287 | + private static bool $coerce = false; |
| 288 | + |
| 289 | + public static function check(mixed $input, string $pointer): string { |
| 290 | + $typed = Constraints\StringConstraint::check($input, $pointer, self::$coerce); |
| 291 | + |
| 292 | + return $typed; |
| 293 | + } |
| 294 | +} |
| 295 | + |
| 296 | +final class ObjectSchemaValidatorPropertiesDefaultsPropertiesDefaultString { |
| 297 | + |
| 298 | + private static bool $coerce = false; |
| 299 | + |
| 300 | + public static function check(mixed $input, string $pointer): string { |
| 301 | + $typed = Constraints\StringConstraint::check($input, $pointer, self::$coerce); |
| 302 | + |
| 303 | + return $typed; |
| 304 | + } |
| 305 | +} |
| 306 | + |
| 307 | +final class ObjectSchemaValidatorPropertiesDefaults { |
| 308 | + |
| 309 | + private static keyset<string> $required = keyset[ |
| 310 | + 'required_string', |
| 311 | + ]; |
| 312 | + private static bool $coerce = false; |
| 313 | + private static keyset<string> $properties = keyset[ |
| 314 | + 'required_string', |
| 315 | + 'default_string', |
| 316 | + ]; |
| 317 | + |
| 318 | + public static function check( |
| 319 | + mixed $input, |
| 320 | + string $pointer, |
| 321 | + ): TObjectSchemaValidatorPropertiesDefaults { |
| 322 | + $typed = Constraints\ObjectConstraint::check($input, $pointer, self::$coerce); |
| 323 | + |
| 324 | + $defaults = dict[ |
| 325 | + 'default_string' => 'test', |
| 326 | + ]; |
| 327 | + $typed = \HH\Lib\Dict\merge($defaults, $typed); |
| 328 | + |
| 329 | + Constraints\ObjectRequiredConstraint::check( |
| 330 | + $typed, |
| 331 | + self::$required, |
| 332 | + $pointer, |
| 333 | + ); |
| 334 | + |
| 335 | + $errors = vec[]; |
| 336 | + $output = shape(); |
| 337 | + |
| 338 | + if (\HH\Lib\C\contains_key($typed, 'required_string')) { |
| 339 | + try { |
| 340 | + $output['required_string'] = ObjectSchemaValidatorPropertiesDefaultsPropertiesRequiredString::check( |
| 341 | + $typed['required_string'], |
| 342 | + JsonSchema\get_pointer($pointer, 'required_string'), |
| 343 | + ); |
| 344 | + } catch (JsonSchema\InvalidFieldException $e) { |
| 345 | + $errors = \HH\Lib\Vec\concat($errors, $e->errors); |
| 346 | + } |
| 347 | + } |
| 348 | + |
| 349 | + if (\HH\Lib\C\contains_key($typed, 'default_string')) { |
| 350 | + try { |
| 351 | + $output['default_string'] = ObjectSchemaValidatorPropertiesDefaultsPropertiesDefaultString::check( |
| 352 | + $typed['default_string'], |
| 353 | + JsonSchema\get_pointer($pointer, 'default_string'), |
| 354 | + ); |
| 355 | + } catch (JsonSchema\InvalidFieldException $e) { |
| 356 | + $errors = \HH\Lib\Vec\concat($errors, $e->errors); |
| 357 | + } |
| 358 | + } |
| 359 | + |
| 360 | + /*HHAST_IGNORE_ERROR[UnusedVariable] Some loops generated with this statement do not use their $value*/ |
| 361 | + foreach ($typed as $key => $value) { |
| 362 | + if (\HH\Lib\C\contains_key(self::$properties, $key)) { |
| 363 | + continue; |
| 364 | + } |
| 365 | + |
| 366 | + $errors[] = shape( |
| 367 | + 'code' => JsonSchema\FieldErrorCode::FAILED_CONSTRAINT, |
| 368 | + 'message' => "invalid additional property: {$key}", |
| 369 | + 'constraint' => shape( |
| 370 | + 'type' => JsonSchema\FieldErrorConstraint::ADDITIONAL_PROPERTIES, |
| 371 | + 'got' => $key, |
| 372 | + ), |
| 373 | + ); |
| 374 | + } |
| 375 | + |
| 376 | + if (\HH\Lib\C\count($errors)) { |
| 377 | + throw new JsonSchema\InvalidFieldException($pointer, $errors); |
| 378 | + } |
| 379 | + |
| 380 | + /* HH_IGNORE_ERROR[4163] */ |
| 381 | + return $output; |
| 382 | + } |
| 383 | +} |
| 384 | + |
279 | 385 | final class ObjectSchemaValidatorPropertiesOnlyPatternPropertiesPatternProperties0 { |
280 | 386 |
|
281 | 387 | private static bool $coerce = false; |
@@ -1455,6 +1561,17 @@ public static function check( |
1455 | 1561 | } |
1456 | 1562 | } |
1457 | 1563 |
|
| 1564 | + if (\HH\Lib\C\contains_key($typed, 'defaults')) { |
| 1565 | + try { |
| 1566 | + $output['defaults'] = ObjectSchemaValidatorPropertiesDefaults::check( |
| 1567 | + $typed['defaults'], |
| 1568 | + JsonSchema\get_pointer($pointer, 'defaults'), |
| 1569 | + ); |
| 1570 | + } catch (JsonSchema\InvalidFieldException $e) { |
| 1571 | + $errors = \HH\Lib\Vec\concat($errors, $e->errors); |
| 1572 | + } |
| 1573 | + } |
| 1574 | + |
1458 | 1575 | if (\HH\Lib\C\contains_key($typed, 'only_pattern_properties')) { |
1459 | 1576 | try { |
1460 | 1577 | $output['only_pattern_properties'] = ObjectSchemaValidatorPropertiesOnlyPatternProperties::check( |
|
0 commit comments