public function validJSON($attribute) { if ($this->{$attribute}) { if (!\CJSON::decode($this->{$attribute})) { $this->addError($attribute, $this->getAttributeLabel($attribute) . ' must be valid JSON'); } } }