classJsonSchemaFile
final class JsonSchemaFile
Validates a document against a JSON Schema read from a file.
Methods§
public function validate(mixed $data, string $schema, string $file): voidValidates a document.
Parameters
$data | mixed | The decoded document |
$schema | string | The schema file |
$file | string | The document file, used in error messages |
Throws
InvalidInputException When the schema cannot be read or is neither an object nor a Boolean, or the document breaks itJsonException When the schema is not JSONTest cases 6
JsonSchemaFileTest::testValidateAcceptsConformingDocumentcallsJsonSchemaFileTest::testValidateRejectsDirectoryAsSchemacallsJsonSchemaFileTest::testValidateRejectsDocumentBreakingSchemacallsJsonSchemaFileTest::testValidateRejectsMissingSchemacallsJsonSchemaFileTest::testValidateRejectsSchemaThatIsNeitherObjectNorBooleancallsJsonSchemaFileTest::testValidateRejectsSchemaThatIsNotJsoncalls
Called from 2
Calls 11
- function-call
is_fileline 29 - function-call
file_get_contentsline 29 - new InvalidInputException line 31
- function-call
json_decodeline 33 - function-call
is_objectline 34 - function-call
is_boolline 34 - method-call
Validator::validate()line 37 - new
Validatorline 37 - function-call
json_encodeline 39 - method-call
ErrorFormatter::format()line 39 - new
ErrorFormatterline 39
Test cases 21§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
JsonSchemaFileTest::testValidateAcceptsConformingDocumentcallsJsonSchemaFileTest::testValidateRejectsDirectoryAsSchemacallsJsonSchemaFileTest::testValidateRejectsDocumentBreakingSchemacallsJsonSchemaFileTest::testValidateRejectsMissingSchemacallsJsonSchemaFileTest::testValidateRejectsSchemaThatIsNeitherObjectNorBooleancallsJsonSchemaFileTest::testValidateRejectsSchemaThatIsNotJsoncalls
Other tests reaching this symbol 15
DefinitionReaderTestcallsDocumentReaderTestcallsLoaderTestcallsReferenceTestcallsMarkdownDocumentTestcallsSchemaValidatorTestcallsApplicationTestcallsCommandHandlerTestcallsCommandLineTestcallsExecutorTestcallsFormatterTestcallsAnalyzerTestcallsCoverageTestcallsSnapshotTestcallsVerifierTestcalls