abacaphiliac/zend-json-schema-validator

A ZF2 validator for justinrainbow/json-schema.

1.0.0 2019-08-04 01:06 UTC

This package is auto-updated.

Last update: 2024-12-05 08:49:28 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.