|
| 1 | +<?hh // strict |
| 2 | +/** |
| 3 | + * This file is generated. Do not modify it manually! |
| 4 | + * |
| 5 | + * To re-generate this file run `make test` |
| 6 | + * |
| 7 | + * |
| 8 | + * @generated SignedSource<<2a4a4e3e9c399de1de58724be9cf4435>> |
| 9 | + */ |
| 10 | +namespace Slack\Hack\JsonSchema\Tests\Generated; |
| 11 | +use namespace Slack\Hack\JsonSchema; |
| 12 | +use namespace Slack\Hack\JsonSchema\Constraints; |
| 13 | + |
| 14 | +type TMultipleOfValidator = shape( |
| 15 | + ?'a_multiple_of_five_int' => int, |
| 16 | + ?'a_multiple_of_1_point_one_repeating_number' => num, |
| 17 | + ... |
| 18 | +); |
| 19 | + |
| 20 | +final class MultipleOfValidatorPropertiesAMultipleOfFiveInt { |
| 21 | + |
| 22 | + private static num $devisorForMultipleOf = 5; |
| 23 | + private static bool $coerce = false; |
| 24 | + |
| 25 | + public static function check(mixed $input, string $pointer): int { |
| 26 | + $typed = |
| 27 | + Constraints\IntegerConstraint::check($input, $pointer, self::$coerce); |
| 28 | + |
| 29 | + Constraints\NumberMultipleOfConstraint::check( |
| 30 | + $typed, |
| 31 | + self::$devisorForMultipleOf, |
| 32 | + $pointer, |
| 33 | + ); |
| 34 | + return $typed; |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +final class MultipleOfValidatorPropertiesAMultipleOf1PointOneRepeatingNumber { |
| 39 | + |
| 40 | + private static num $devisorForMultipleOf = 1.1111111111111; |
| 41 | + private static bool $coerce = false; |
| 42 | + |
| 43 | + public static function check(mixed $input, string $pointer): num { |
| 44 | + $typed = Constraints\NumberConstraint::check($input, $pointer, self::$coerce); |
| 45 | + |
| 46 | + Constraints\NumberMultipleOfConstraint::check( |
| 47 | + $typed, |
| 48 | + self::$devisorForMultipleOf, |
| 49 | + $pointer, |
| 50 | + ); |
| 51 | + return $typed; |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +final class MultipleOfValidator |
| 56 | + extends JsonSchema\BaseValidator<TMultipleOfValidator> { |
| 57 | + |
| 58 | + private static bool $coerce = false; |
| 59 | + |
| 60 | + public static function check( |
| 61 | + mixed $input, |
| 62 | + string $pointer, |
| 63 | + ): TMultipleOfValidator { |
| 64 | + $typed = Constraints\ObjectConstraint::check($input, $pointer, self::$coerce); |
| 65 | + |
| 66 | + $errors = vec[]; |
| 67 | + $output = shape(); |
| 68 | + |
| 69 | + /*HHAST_IGNORE_ERROR[UnusedVariable] Some loops generated with this statement do not use their $value*/ |
| 70 | + foreach ($typed as $key => $value) { |
| 71 | + /* HH_IGNORE_ERROR[4051] allow dynamic access to preserve input. See comment in the codegen lib for reasoning and alternatives if needed. */ |
| 72 | + $output[$key] = $value; |
| 73 | + } |
| 74 | + |
| 75 | + if (\HH\Lib\C\contains_key($typed, 'a_multiple_of_five_int')) { |
| 76 | + try { |
| 77 | + $output['a_multiple_of_five_int'] = MultipleOfValidatorPropertiesAMultipleOfFiveInt::check( |
| 78 | + $typed['a_multiple_of_five_int'], |
| 79 | + JsonSchema\get_pointer($pointer, 'a_multiple_of_five_int'), |
| 80 | + ); |
| 81 | + } catch (JsonSchema\InvalidFieldException $e) { |
| 82 | + $errors = \HH\Lib\Vec\concat($errors, $e->errors); |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + if (\HH\Lib\C\contains_key($typed, 'a_multiple_of_1_point_one_repeating_number')) { |
| 87 | + try { |
| 88 | + $output['a_multiple_of_1_point_one_repeating_number'] = MultipleOfValidatorPropertiesAMultipleOf1PointOneRepeatingNumber::check( |
| 89 | + $typed['a_multiple_of_1_point_one_repeating_number'], |
| 90 | + JsonSchema\get_pointer($pointer, 'a_multiple_of_1_point_one_repeating_number'), |
| 91 | + ); |
| 92 | + } catch (JsonSchema\InvalidFieldException $e) { |
| 93 | + $errors = \HH\Lib\Vec\concat($errors, $e->errors); |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + if (\HH\Lib\C\count($errors)) { |
| 98 | + throw new JsonSchema\InvalidFieldException($pointer, $errors); |
| 99 | + } |
| 100 | + |
| 101 | + /* HH_IGNORE_ERROR[4163] */ |
| 102 | + return $output; |
| 103 | + } |
| 104 | + |
| 105 | + <<__Override>> |
| 106 | + protected function process(): TMultipleOfValidator { |
| 107 | + return self::check($this->input, $this->pointer); |
| 108 | + } |
| 109 | +} |
0 commit comments