magp / yii2-json-schema-validator
A Yii2 extension that provides a validator class for JSON Schema validation.
Installs: 5 346
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- swaggest/json-schema: *
- yiisoft/yii2: 2.*
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-29 05:34:49 UTC
README
A Yii 2 extension that provides a validation class that wraps JSON Schema for PHP.
Installation
$ composer require magp/yii2-json-schema-validator
Usage
Model class example:
<?php namespace app\models; use magp\yii2jsv\JsonSchemaValidator; use Yii; use yii\base\Model; class YourCustomModel extends Model { public $json; public function rules() { return [ [ 'json', JsonSchemaValidator::className(), 'schema' => 'file://' . Yii::getAlias('@app/path/to/schema.json'), /* or URL 'schema' => 'https://example.com/path/to/schema.json', */ ], ]; } }
See json-schema for details how to describe JSON schema.