| 1 | <?php |
||
| 18 | class Json extends Rule |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * A constant that will be used when the value is not a valid JSON string. |
||
| 22 | */ |
||
| 23 | const INVALID_FORMAT = 'Json::INVALID_VALUE'; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * The message templates which can be returned by this validator. |
||
| 27 | * |
||
| 28 | * @var array |
||
| 29 | */ |
||
| 30 | protected $messageTemplates = [ |
||
| 31 | self::INVALID_FORMAT => '{{ name }} must be a valid JSON string', |
||
| 32 | ]; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Validates if the value is a valid JSON string. |
||
| 36 | * |
||
| 37 | * @param mixed $value |
||
| 38 | * @return bool |
||
| 39 | */ |
||
| 40 | 11 | public function validate($value) |
|
| 51 | } |
||
| 52 |