jobcloud / avro-validator
Installs: 3 273
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 18
Forks: 2
Open Issues: 2
Requires
- php: ^8.0
- ext-json: *
- symfony/console: ^5.1.5 || ^6.0 || ^7.0
Requires (Dev)
- ergebnis/phpstan-rules: ^2.0.0
- friends-of-phpspec/phpspec-code-coverage: dev-master@dev
- infection/infection: ^0.26 || ^0.29
- infection/phpspec-adapter: ^0.2.1
- phpspec/phpspec: ^7.0
- phpstan/phpstan: ^1.9.0
- phpstan/phpstan-deprecation-rules: ^1.1.0
- phpstan/phpstan-strict-rules: ^1.4.0
- rregeer/phpunit-coverage-check: ^0.3.1
- squizlabs/php_codesniffer: ^3.4.2
README
Install
composer require jobcloud/avro-validator
Usage
$recordRegistry = RecordRegistry::fromSchema(file_get_contents(__DIR__ . '/schema.json')); $validator = new Validator($recordRegistry); var_dump($validator->validate( '{"payload": "here comes the payload to validate against the schema"}}', 'marketplace.ecommerce.entity.order' ));
Command
There's a command making use of the validator shipped with this package:
$ bin/avro-validator validate
Description:
Validates a payload against a schema
Usage:
validate [options] [--] <schema> <namespace> [<payload>]
Arguments:
schema Path to the schema file
namespace Schema namespace
payload Path to the payload file
Options:
-f, --format=FORMAT Output format of the result [default: "pretty"]
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug