PHP code example of dstotijn / yii2-json-schema-validator
1. Go to this page and download the library: Download dstotijn/yii2-json-schema-validator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dstotijn / yii2-json-schema-validator example snippets
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',
*/
],
];
}
}