PHP 클래스 Webmozart\Json\JsonValidator

This class is a wrapper for {@link Validator} that adds exceptions and validation of schema files. A few edge cases that are not handled by {@link Validator} are handled by this class.
부터: 1.0
저자: Bernhard Schussek ([email protected])
파일 보기 프로젝트 열기: webmozart/json 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( JsonSchema\Validator $validator = null, JsonSchema\Uri\UriRetriever $uriRetriever = null, JsonSchema\UriResolverInterface $uriResolver = null ) JsonValidator constructor.
validate ( mixed $data, string | object | null $schema = null ) : string[] Validates JSON data against a schema.

비공개 메소드들

메소드 설명
assertSchemaValid ( $schema )
loadSchema ( $file )

메소드 상세

__construct() 공개 메소드

JsonValidator constructor.
public __construct ( JsonSchema\Validator $validator = null, JsonSchema\Uri\UriRetriever $uriRetriever = null, JsonSchema\UriResolverInterface $uriResolver = null )
$validator JsonSchema\Validator JsonSchema\Validator instance to use
$uriRetriever JsonSchema\Uri\UriRetriever The retriever for fetching JSON schemas
$uriResolver JsonSchema\UriResolverInterface The resolver for URIs

validate() 공개 메소드

The schema may be passed as file path or as object returned from json_decode($schemaFile).
public validate ( mixed $data, string | object | null $schema = null ) : string[]
$data mixed The decoded JSON data
$schema string | object | null The schema file or object. If `null`, the validator will look for a `$schema` property
리턴 string[] The errors found during validation. Returns an empty array if no errors were found