<commit_before># Yii 2 JSON Validator

[![Build Status](https://travis-ci.org/romi45/yii2-json-validator.svg?branch=master)](https://travis-ci.org/romi45/yii2-json-validator)

A Yii2 extension that provides JSON validation

## Installation

```
$ composer require romi45/yii2-json-validator
```

## Usage

Model class example:

```php
<?php

namespace app\models;

use Yii;
use yii\base\Model;
use romi45\yii2jsonvalidator\JsonValidator;

class MyModel extends Model
{
    public $json;

    public function rules()
    {
        return [
            [
                'property_to_validate',
                JsonValidator::class,
                'invalidJsonMsg' => 'OMG!!! this is a custom error message!'
            ],
        ];
    }
}
```

View public properties in class
[JsonValidator](https://github.com/romi45/yii2-json-validator/blob/master/JsonValidator.php)
to get info about all available options.<commit_msg>Release commit<commit_after># Yii 2 JSON Validator

[![Build Status](https://travis-ci.org/romi45/yii2-json-validator.svg)](https://travis-ci.org/romi45/yii2-json-validator)

A Yii2 extension that provides JSON validation

## Installation

```
$ composer require romi45/yii2-json-validator
```

## Usage

Model class example:

```php
<?php

namespace app\models;

use Yii;
use yii\base\Model;
use romi45\yii2jsonvalidator\JsonValidator;

class MyModel extends Model
{
    public $json;

    public function rules()
    {
        return [
            [
                'property_to_validate',
                JsonValidator::class,
                'invalidJsonMsg' => 'OMG!!! this is a custom error message!'
            ]
        ];
    }
}
```

View public properties in class
[JsonValidator](https://github.com/romi45/yii2-json-validator/blob/master/JsonValidator.php)
to get info about all available options.
{'fraction_non_alphanumeric': 0.12159214830970556, 'fraction_numerical': 0.018538713195201745, 'mean_word_length': 2.9377682403433476, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1132350', 'n_tokens_mistral': 603, 'n_tokens_neox': 584, 'n_words': 130}