2017 © Pedro PelĂĄez
 

library psr7-validation

PSR-7 middleware for JSON schema validation

image

mittwald/psr7-validation

PSR-7 middleware for JSON schema validation

  • Monday, April 16, 2018
  • by mittwald-typo3
  • Repository
  • 3 Watchers
  • 3 Stars
  • 2,379 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 17 % Grown

The README.md

PSR-7 validation middlewares

Build Status, (*1)

Synposis

This package contains a PSR-7 middleware for validating HTTP requests, especially using JSON schema validation., (*2)

Warning: This package is still under development; its API can change at any time without notice. Use at own risk., (*3)

License

This package is MIT-licensed., (*4)

Examples

Validating request bodies using a JSON schema (using the Slim framework):, (*5)

$app->post('/customers', $handler)
    ->add(new ValidationMiddleware(
        Factory::buildJsonValidatorFromUri('path/to/json-schema.json')
    ));

Validating request bodies using a Swagger specification file:, (*6)

$app->post('/customers', $handler)
    ->add(new ValidationMiddleware(
        Factory::buildJsonValidatorFromSwaggerDefinition('path/to/swagger.json', 'MyType')
    ));

Validating request bodies using a custom validator (using PHP 7's anonymous classes, for no other reason because I can):, (*7)

$app->post('/customers', $handler)
    ->add(new ValidationMiddleware(
        new class implements ValidatorInterface {
            public function validateJson($jsonDocument, ValidationResult $result) {
                $result->addErrorForProperty('customernumber', 'Foo');
            }
        }
    ));

Combining multiple validators:, (*8)

$app->post('/customers', $handler)
    ->add(new ValidationMiddleware(
        new CombinedValidator(
            Factory::buildJsonValidatorFromUri('path/to/schema.json'),
            new MyVerySpecialCustomValidator()
        )
    ));

The Versions

16/04 2018

dev-master

9999999-dev

PSR-7 middleware for JSON schema validation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Baris GĂŒrgöl

16/04 2018

v1.1.0

1.1.0.0

PSR-7 middleware for JSON schema validation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Baris GĂŒrgöl

22/07 2016

v1.0.0-alpha1

1.0.0.0-alpha1

PSR-7 middleware for JSON schema validation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Baris GĂŒrgöl