abacaphiliac/zend-json-schema-validator

A ZF2 validator for justinrainbow/json-schema.

0.1.1 2016-06-11 15:54 UTC

README

Scrutinizer Code Quality Code Coverage Build Status

abacaphiliac/zend-json-schema-validator

A ZF2 validator for justinrainbow/json-schema.

Installation

composer require abacaphiliac/zend-json-schema-validator

Usage

Use it inline:

$validator = new \Abacaphiliac\Zend\Validator\JsonSchema(array(
  'file' => '/path/to/your/schema.json',
));
if (!$validator->isValid('{"Foo":"Bar"}')) {
    $validationMessages = $validator->getMessages();
}

Hook it up to an Apigility input-filter-spec:

return array(
    'input_filter_specs' => array(
        'YourApi\\V1\\Rest\\YourService\\Validator' => array(
            array(
                'name' => 'YourJsonParam',
                'validators' => array(
                    array(
                        'name' => 'IntegrationConfiguration\\Validator\\JsonSchema',
                        'options' => array(
                            'file' => dirname(dirname(dirname(__DIR__))) . '/config/json-schema/IntegrationConfiguration/V1/Rest/OutboundDocumentation/configurations-config.json',
                        ),
                    ),
                )
            ),
        ),
    ),
);

Dependencies

See composer.json.

Contributing

composer update && vendor/bin/phing

This library attempts to comply with PSR-1, PSR-2, and PSR-4. If you notice compliance oversights, please send a patch via pull request.