PHP code example of sangroya / yii2-json-schema-validator
1. Go to this page and download the library: Download sangroya/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/ */
sangroya / yii2-json-schema-validator example snippets
namespace app\models;
use sangroya\jsonschema\JsonSchemaValidator;
use Yii;
use yii\base\Model;
class MyModel extends Model
{
public $json;
public function rules()
{
return [
[
'json',
JsonSchemaValidator::className(),
'schema' => 'file://' . Yii::getAlias('@app/path/to/schema.json'),
/* or URL
'schema' => 'https://test-example.com/path/to/schema.json',
*/
],
];
}
}