From a44cc1d2e3c0f147e91a5c052ac7fd879e34e706 Mon Sep 17 00:00:00 2001 From: Eole Date: Thu, 21 Jan 2016 10:29:26 +0100 Subject: Init Server Composer Components --- .../json-schema/src/JsonSchema/Validator.php | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 server/vendor/justinrainbow/json-schema/src/JsonSchema/Validator.php (limited to 'server/vendor/justinrainbow/json-schema/src/JsonSchema/Validator.php') diff --git a/server/vendor/justinrainbow/json-schema/src/JsonSchema/Validator.php b/server/vendor/justinrainbow/json-schema/src/JsonSchema/Validator.php new file mode 100644 index 0000000..14dbb60 --- /dev/null +++ b/server/vendor/justinrainbow/json-schema/src/JsonSchema/Validator.php @@ -0,0 +1,40 @@ + + * @author Bruno Prieto Reis + * @see README.md + */ +class Validator extends Constraint +{ + const SCHEMA_MEDIA_TYPE = 'application/schema+json'; + + /** + * Validates the given data against the schema and returns an object containing the results + * Both the php object and the schema are supposed to be a result of a json_decode call. + * The validation works as defined by the schema proposal in http://json-schema.org + * + * {@inheritDoc} + */ + public function check($value, $schema = null, $path = null, $i = null) + { + $validator = $this->getFactory()->createInstanceFor('schema'); + $validator->check($value, $schema); + + $this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR)); + } +} -- cgit v1.2.3