determine if given data is a valid json data

@param $key
@param $datas
@param $rule
480576
protected function runJson($key, $datas, $rule)
    {
        if (json_decode($datas[$key]) === false) {
            $this->fails[] = $messageKey = "json.$key";

            $this->addMessage($key, $rule, $messageKey);
        }
    }
493678
private function validateRulesHasPlaceHolder($key, $rule, $isValid)
    {
        $string = string_split($rule, ':');

        if (!string_has($string[1], ',')) {
            return $this->doValidateData($string[0], $string[1], $isValid, $key);
        }

        return $this->doValidateData($string[0], $key, $isValid, $string[1]);
    }
1299776
protected function runNumeric($key, $datas, $rule = '')
    {

        if (!isset($datas[$key])) {
            if (!is_numeric($datas[$key])) {
                $this->fails[] = $messageKey = "numeric.$key";

                $this->addMessage($key, $rule, $messageKey);
            }
        }
    }
184514
public function validate($data, array $rules, $context = null): ValidatorInterface
    {
        return new Validator($data, $rules, $context, $this);
    }
508421
public function validateData(array $data, array $rules, array $messages)
    {
        if ($rules) {
            $this->customValidator->setData($data);
            $this->customValidator->setRules($rules);
            $this->customValidator->setCustomMessages($messages);

            //if the validator fails, kick back the errors
            if ($this->customValidator->fails()) {
                return implode('. ', $this->customValidator->messages()->all());
            }
        }

        return true;
    }
1367247
public static function required(Validator $validator, $data, $pattern, $rule)
    {
        // Check pattern is present
        if (!ArrDots::has($data, $pattern, $validator::WILD)) {
            $validator->addError($pattern, $rule);
        }

        // Check value is not null
        foreach (Validator::getValues($data, $pattern) as $attribute => $value) {
            if (null !== $value) {
                continue;
            }

            $validator->addError($attribute, $rule);
        }
    }
483030
protected function extractInputFromRules($data, array $rules): array
    {
        if (\is_object($data)) {
            $data = (array)$data;
        }

        $result = [];
        $additional = [];
        $arrays = [];
        $isGlobalArray = false;

        foreach ($rules as $rule => $value) {
            if (Str::contains($rule, '.')) {
                $attributes = explode('.', $rule);
                $rule = array_shift($attributes);
                $key = implode('.', $attributes);

                if (\is_array($data)) {
                    if (array_key_exists($rule, $data)) {
                        $additional[$rule][$key] = $value;
                    } elseif ($rule === '*') {
                        $arrays[$key] = $value;
                    }
                }
            } elseif (\is_array($data) && array_key_exists($rule, $data)) {
                $result[$rule] = $data[$rule];
            } elseif ($rule === '*' && \is_array($data)) {
                $isGlobalArray = true;
            }
        }

        if (!empty($arrays)) {
            $result = [];
            foreach ($data as $item) {
                $result[] = $this->extractInputFromRules($item, $arrays);
            }

            return $result;
        } elseif ($isGlobalArray) {
            return $data;
        }

        foreach ($additional as $key => $item) {
            $result[$key] = $this->extractInputFromRules($data[$key], $item);
        }

        return $result;
    }
251857
protected function isAllVoidValue($key, $rule = 'required_without')
    {
        $fields  = $this->getParamField($this->rules[ $key ], $rule);
        $require = new Rules\Required;
        $errors  = [];

        foreach ($fields as $field) {
            if (!isset($this->inputs[ $field ])) {
                throw new \InvalidArgumentException(htmlspecialchars(
                    "The provided $field field does not exist."
                ));
            }
            $require->execute('required', $field, $this->inputs[ $field ], false, true);
            $errors += $require->getErrors();
        }

        return count($errors) == count($fields);
    }
277796
private function checkDataSet(array $data, $key, $isNew)
    {
        $keyExists = array_key_exists($key, $data);

        if (($isNew && !($keyExists && $data[$key] !== null)) || (!$keyExists || $data[$key] === null)) {
            throw new MissingShippingAttributeException($key);
        }

        return $keyExists;
    }
718530
protected function runEmail($key, $datas, $rule)
    {

        $email = $datas[$key];
        if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
            $this->fails[] = $messageKey = "email.$key";

            $this->addMessage($key, $rule, $messageKey);
        }

    }
147263
private function serializeJsonValidationRules(string $rulesPath, string $queriesValPath): array
    {
        // JSON API data validation rules
        $dataSerializer = new JsonApiDataRulesSerializer(new BlockSerializer());
        foreach ($this->selectClasses($rulesPath, JsonApiDataRulesInterface::class) as $rulesClass) {
            $dataSerializer->addRulesFromClass($rulesClass);
        }

        // JSON API query validation rules
        $querySerializer = new JsonApiQueryRulesSerializer(new BlockSerializer());
        // Add predefined rules for queries...
        $querySerializer->addRulesFromClass(DefaultQueryValidationRules::class);
        // ... and add user defined ones.
        foreach ($this->selectClasses($queriesValPath, JsonApiQueryRulesInterface::class) as $rulesClass) {
            $querySerializer->addRulesFromClass($rulesClass);
        }

        return [
            static::JSON_API_DATA_VALIDATION_RULES_SERIALIZED    => $dataSerializer->getData(),
            static::JSON_API_QUERIES_VALIDATION_RULES_SERIALIZED => $querySerializer->getData(),
        ];
    }
813862
protected static function inputValidate($data, string $jsonShemaFile): bool
    {
        $fullPath = cfg::baseDir() . cfg::JSON_SCHEMA . cfg::DS;
        $jsonSchema = $fullPath . $jsonShemaFile;

        if (Json::validate($data, $jsonSchema)) {
            return true;
        }

        return false;
    }
1231802
protected function isOneVoidValue($key, $rule = 'required_with')
    {
        $fields  = $this->getParamField($this->rules[ $key ], $rule);
        $require = new Rules\Required;

        foreach ($fields as $field) {
            if (!isset($this->inputs[ $field ])) {
                throw new \InvalidArgumentException(htmlspecialchars(
                    "The provided $field field does not exist."
                ));
            }
            $require->execute('required', $field, $this->inputs[ $field ], false, true);
            if ($require->hasErrors()) {
                return true;
            }
        }

        return false;
    }
135964
protected function lt($value, $rule, $data)
    {
        $val = $this->getDataValue($data, $rule);

        return !is_null($val) && $value < $val;
    }
941958
protected function onInvalidEventAttributeValidate($key, $check = [], $rule = NULL)
    {
        $this->validate[] = $rule ?: $key;

        return $this->required()->onInvalidEventCustomValidity($key, $check);
    }
399283
protected function generate_error_message( $rule, $key, $params )
	{
		$params = $this->get_error_message_params( $key, $params );
		return __( ClanCats::$config->get( 'validation.language_prefix' ).'.'.$rule, $params );
	}
152158
protected function hasRule(array $keyRules, $ruleNames)
    {

        $ruleNames = (array)$ruleNames;

        foreach ($keyRules as $ruleName=>$parameters) {
            if (in_array($ruleName, $ruleNames)) {
                return true;
            }
        }

        return false;
    }