hack-json-schema
hack-json-schema copied to clipboard
Generate Hack JSON Schema validators based on a JSON Schema.
If `anyOf` references a single schema, there is an error when using unique references here: https://github.com/slackhq/hack-json-schema/blob/7d946d35e9a782bf1af8bf450b35efdece6ab514/src/Codegen/Constraints/UntypedBuilder.php#L358. We require the schema to be built before accessing the type.
Currently tests rely on: - parsing a JSON schema - generating a validator from it - using that validator to execute tests If these test files are marked as strict,...
- [ ] `multipleOf` - [ ] `minimum`, `exclusiveMinimum`, `maximum`, `exclusiveMaximum` (`exclusiveMinimum` and `exclusiveMaximum` should be numbers not booleans)
We try and optimize `anyOf` checks for types that all have a specific string field that acts like an enum. This optimized check isn't handling if that provided value is...
```HACK // From hack-json-schema/src/BaseValidator.php interface Validator { public function validate(): void; public function isValid(): bool; public function getErrors(): vec; public function getValidatedInput(): ?T; // ^^ nullable T } abstract class...
Adding a `pattern` property to a schema is supposed to validate a value using the provided regular expression. This is done in generated code using `StringPatternConstraint`: ```Hack class StringPatternConstraint {...
```HACK use type Slack\Hack\JsonSchema\Codegen\Codegen; $schemas = vec['/path/to/json-schema-1.json', '/path/to/json-schema-2.json', '/path/to/json-schema-3.json']; Codegen::forPaths($schemas, shape( 'validator' => shape( 'refs' => shape( 'unique' => shape( 'source_root' => '/path/to', 'output_root' => '/path/gen' ) ) ), ))->build();...