abacaphiliac/zend-json-schema-validator

A ZF2 validator for justinrainbow/json-schema.

Installs: 67 499

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/abacaphiliac/zend-json-schema-validator

1.0.0 2019-08-04 01:06 UTC

This package is auto-updated.

Last update: 2025-10-05 10:47:17 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.