dstotijn / yii2-json-schema-validator
一个为JSON Schema验证提供验证类扩展的Yii2插件。
1.0.0
2016-07-13 13:43 UTC
Requires
- justinrainbow/json-schema: ~1.3
- yiisoft/yii2: 2.*
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-28 16:53:26 UTC
README
一个提供包装JSON Schema for PHP验证类的Yii 2扩展。
安装
$ composer require dstotijn/yii2-json-schema-validator
用法
模型类示例
<?php namespace app\models; use dstotijn\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', */ ], ]; } }
有关如何描述JSON Schema的详细信息,请参阅 json-schema。
请查看JsonSchemaValidator类中的公共属性,以获取有关所有可用选项的信息。