OpenMediaVault  3.0 (Erasmus)
The open network attached storage solution
Public Member Functions | Protected Member Functions | List of all members
OMV\Json\Schema Class Reference
Inheritance diagram for OMV\Json\Schema:
OMV\DataModel\Schema

Public Member Functions

 __construct ($schema)
 
 addProperty ($path, array $schema=array())
 
 removeProperty ($path)
 
 getAssoc ()
 
 getAssocByPath ($name)
 
 validate ($value, $name="")
 

Protected Member Functions

 validateType ($value, $schema, $name)
 
 validateAny ($value, $schema, $name)
 
 validateBoolean ($value, $schema, $name)
 
 validateInteger ($value, $schema, $name)
 
 validateNumber ($value, $schema, $name)
 
 validateString ($value, $schema, $name)
 
 validateArray ($value, $schema, $name)
 
 validateObject ($value, $schema, $name)
 
 validateNull ($value, $schema, $name)
 
 checkMinimum ($value, $schema, $name)
 
 checkMaximum ($value, $schema, $name)
 
 checkExclusiveMinimum ($value, $schema, $name)
 
 checkExclusiveMaximum ($value, $schema, $name)
 
 checkMinLength ($value, $schema, $name)
 
 checkMaxLength ($value, $schema, $name)
 
 checkPattern ($value, $schema, $name)
 
 checkFormat ($value, $schema, $name)
 
 checkEnum ($value, $schema, $name)
 
 checkMinItems ($value, $schema, $name)
 
 checkMaxItems ($value, $schema, $name)
 
 checkProperties ($value, $schema, $name)
 
 checkItems ($value, $schema, $name)
 
 checkOneOf ($value, $schema, $name)
 

Detailed Description

Implements a JSON schema validator.

See also
https://tools.ietf.org/html/draft-zyp-json-schema-03
http://json-schema.org/latest/json-schema-core.html
http://json-schema.org/latest/json-schema-validation.html

Constructor & Destructor Documentation

OMV\Json\Schema::__construct (   $schema)
Parameters
schemaThe schema as associative array in JSON schema syntax.

Member Function Documentation

OMV\Json\Schema::addProperty (   $path,
array  $schema = array() 
)

Add a new property to the schema at runtime.

Parameters
pathThe path of the property, e.g. "aaa.bbb.ccc", where 'ccc' is the name of the property to add.
schemaThe schema of the property to add, e.g. array("type" => "integer", "default" => 100)
OMV\Json\Schema::checkFormat (   $value,
  $schema,
  $name 
)
protected
OMV\Json\Schema::getAssoc ( )
final

Returns the JSON schema.

Returns
The JSON schema as associative array.
OMV\Json\Schema::getAssocByPath (   $name)
final

Returns the JSON schema by the given path.

Returns
The JSON schema as associative array.
OMV\Json\Schema::removeProperty (   $path)

Remove a property from the schema at runtime.

Parameters
pathThe path of the property to remove.
OMV\Json\Schema::validate (   $value,
  $name = "" 
)
final

Validate the given value.

Parameters
valueThe value to validate.
nameThe JSON path of the entity to validate, e.g. 'aa.bb.cc', defaults to an empty string. Use an empty value for the root.
Returns
None.
Exceptions

The documentation for this class was generated from the following file: