classSchemaValidator
final class SchemaValidator
Validates documents against the bundled JSON Schemas and any local schema they declare.
A declared $schema is either the bundled schema's published URI, which resolves offline, or a local JSON Schema path that adds constraints to the bundled schema.
Constants§
public const BASE = 'https://raw.githubusercontent.com/k-kinzal/ztd-query-php/main/packages/require…The published location of the bundled schemas, accepted as $schema without a download.
Methods§
public function validate(mixed $data, string $kind, string $file): voidValidates a document.
Parameters
$data | mixed | The decoded document |
$kind | string | "config" or "definition", naming the bundled schema |
$file | string | The document file |
Throws
InvalidInputException When the document breaks a schema, or declares a remote or unreadable oneJsonException When a schema is not JSONTest cases 10
SchemaValidatorTest::testValidateAcceptsBundledSchemaUricallsSchemaValidatorTest::testValidateAcceptsDocumentWithoutDeclarationcallsSchemaValidatorTest::testValidateAcceptsRelativeLocalSchemacallsSchemaValidatorTest::testValidateAppliesBundledSchemaBeforeDeclaredOnecallsSchemaValidatorTest::testValidateReadsAbsoluteLocalSchemacallsSchemaValidatorTest::testValidateRejectsDocumentBreakingBundledSchemacallsSchemaValidatorTest::testValidateRejectsLocalSchemaThatIsNotJsoncallsSchemaValidatorTest::testValidateRejectsUnknownRemoteSchemacallsSchemaValidatorTest::testValidateRejectsUnreadableLocalSchemacallsSchemaValidatorTest::testValidateResolvesRelativeSchemaAgainstDocumentDirectorycalls
Called from 1
Calls 10
- new JsonSchemaFile line 36
- method-call JsonSchemaFile::validate() line 37
- static-call SchemaValidator::path() line 37
- function-call
is_stringline 40 - new InvalidInputException line 41
- class-const SchemaValidator::BASE() line 43
- static-call DocumentReader::isMarkdown() line 43
- function-call
str_containsline 46 - function-call
str_starts_withline 49 - function-call
dirnameline 49
public static function path(string $name): stringReturns the path of a bundled schema.
Parameters
$name | string | The schema file name |
Returns
string The path within the package's schemas directoryTest cases 1
Called from 2
Calls 1
- function-call
dirnameline 62
Test cases 29§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 14
SchemaValidatorTest::providerBundledDeclarationscallsSchemaValidatorTest::providerUnknownDeclarationscallsSchemaValidatorTest::testBaseIsPublishedSchemaLocationcallsSchemaValidatorTest::testPathLocatesBundledSchemacallsSchemaValidatorTest::testValidateAcceptsBundledSchemaUricallsSchemaValidatorTest::testValidateAcceptsDocumentWithoutDeclarationcallsSchemaValidatorTest::testValidateAcceptsRelativeLocalSchemacallsSchemaValidatorTest::testValidateAppliesBundledSchemaBeforeDeclaredOnecallsSchemaValidatorTest::testValidateReadsAbsoluteLocalSchemacallsSchemaValidatorTest::testValidateRejectsDocumentBreakingBundledSchemacallsSchemaValidatorTest::testValidateRejectsLocalSchemaThatIsNotJsoncallsSchemaValidatorTest::testValidateRejectsUnknownRemoteSchemacallsSchemaValidatorTest::testValidateRejectsUnreadableLocalSchemacallsSchemaValidatorTest::testValidateResolvesRelativeSchemaAgainstDocumentDirectorycalls
Other tests reaching this symbol 15
DefinitionReaderTestcallsDocumentReaderTestcallsLoaderTestcallsDocumentSchemaTest::providerValidDocumentscallsReferenceTestcallsMarkdownDocumentTestcallsApplicationTestcallsCommandHandlerTestcallsCommandLineTestcallsExecutorTestcallsFormatterTest::testFormatKeepsBundledSchemaDeclarationsAndEmptyMapscallsAnalyzerTestcallsCoverageTestcallsSnapshotTestcallsVerifierTestcalls