Perform the validation by an own validator method.

@param string $ruleName
@param array  $vars       The validation variables (input, value, key, resource, locale)
@param array  $parameters The rule parameters (in rules array)

@return bool
166369
protected function validateByOwnMethod($ruleName, array $vars, array $parameters)
    {
        $method = $this->getMethodBySnakeCaseName($ruleName);

        $methodParams = Lambda::mergeArguments([$this, $method], $vars, $parameters);

        return call_user_func_array([$this, $method], $methodParams);
    }
111961
protected function validate($data, $rules=false)
    {
        if(!$rules)
        {
            $modelName = $this->modelFullName;
            $rules = $modelName::$rules;
        }
        $validator = \Validator::make($data, $rules);
        if($validator->fails()) throw new ValidationException($validator);
        return true;
    }
1153633
protected function validate(array $attributes, string $name, array $parameters): bool
    {
        if (! is_null($attributes[$name])) {
            return true;
        }

        $this->addError($name, $parameters, '%s 不能为 Null');

        return false;
    }
152158
protected function hasRule(array $keyRules, $ruleNames)
    {

        $ruleNames = (array)$ruleNames;

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

        return false;
    }
330237
public function rule(array $params)
    {
        if (isset($params['message'])) {
            $message = $params['message'];
            unset($params['message']);
        } else {
            $message = static::getRuleMessage($params[0]);
        }
        $this->_validations[] = [
            'rule' => $params[0],
            'attributes' => (array)$params[1],
            'params' => array_slice($params, 2),
            'message' => $message
        ];
        return $this;
    }
129545
private static function applyValidatorRules($validator, array &$rules)
    {
        $validatorRule = ValidatorRule::getInstance();
        foreach ($rules as $rule) {
            list($functionName, $arguments) = $validatorRule->parseRule($validator, $rule);
            $validator = \call_user_func_array([$validator, $functionName], $arguments);
        }

        return $validator;
    }
226440
public function validate(array $inputs, array $rules)
    {
        $this->inputs = $inputs;

        foreach ($rules as $key => $rule) {
            /**
             * Formatting and validation of each rule
             * eg. name => "required|max:100|alpha"
             */
            foreach (explode("|", $rule) as $masque) {
                // In the box there is a | superflux.
                if (is_int($masque) || Str::len($masque) == "") {
                    continue;
                }

                // Error lists.
                $this->errors[$key] = [];

                // Mask on the required rule
                foreach ($this->compiles as $compile) {
                    $this->{'compile'.$compile}($key, $masque);
                }

                // We clean the list of errors if the key is valid
                if (empty($this->errors[$key])) {
                    unset($this->errors[$key]);
                }
            }
        }

        return new Validate(
            $this->fails,
            $this->last_message,
            $this->errors
        );
    }
90366
protected function ruleFactory(string $name, array $parameters): RuleInterface
	{
		return $this->container->get($this->getRuleClassName($name), $parameters);
	}
843954
public function passes($input, $rules)
    {
        foreach ($rules as $field => $rule) {
            $this->callValidator($input[$field], $field, $rule);
        }
        return ! $this->failed;
    }
532733
final public function validateParameters(array $parameters)
    {
        $parameters = array_map(function ($rules) {
            if (is_bool($rules) and $rules === true) {
                return 'required';
            }

            return $rules;

        }, $parameters);

        $validator = Validator::make(Request::all(), $parameters);

        if ($validator->fails()) {
            throw new MissingParameterException(
                $validator->errors()->getMessages()
            );
        }

        return true;
    }
969121
public static function requiredWith(Validator $validator, $data, $pattern, $rule, $parameters)
    {
        $field   = $parameters[0];
        $isWild  = strpos($field, $validator::WILD) !== false;
        $overlap = Str::overlapLeft($field, $pattern);

        // Check that the pattern and field can be compared
        if ($isWild && $overlap === false) {
            throw new \InvalidArgumentException('Cannot match pattern ('.$pattern.') to field ('.$field.')');
        }

        // If the required with field exists and the pattern field does not
        if (ArrDots::has($data, $field, $validator::WILD) && !ArrDots::has($data, $pattern, $validator::WILD)) {
            $validator->addError($pattern, $rule, [':field' => $field]);
        }

        // Check value is not null
        foreach (Validator::getValues($data, $pattern) as $attribute => $value) {
            $fieldAttribute = $isWild ? Str::overlapLeftMerge($overlap, $attribute, $field) : $field;
            $fieldValue     = ArrDots::get($data, $fieldAttribute);

            if ($fieldValue === null) {
                continue;
            }
            if ($fieldValue !== null && $value !== null) {
                continue;
            }

            $validator->addError($attribute, $rule, [':field' => $fieldAttribute]);
        }
    }
487136
protected function extractParameter(string $parameter, array $variables): array
    {
        $result = preg_match(
            '/^\s*' . self::REGEX_VARIABLE . '(\s*,\s*(?<next>.+))?\s*$/is',
            $parameter,
            $matches
        );

        if ($result === 0) {
            throw new SyntaxErrorException("Invalid parameter list $parameter");
        }

        return empty($matches['next'])
            ? [$this->getValue($matches, $variables)]
            : array_merge(
                [$this->getValue($matches, $variables)],
                $this->extractParameter($matches['next'], $variables)
            );
    }
906252
public function validate(array $params, array $rules, array $messages = [])
    {
        $validator = app(Validator::class)->make($params, $rules, $messages);

        if ($validator->fails()) {
            throw new ValidationException(
                $validator, new JsonResponse($validator->errors()->getMessages(), 422)
            );
        }
    }
258112
public function validateInput($inputName, $rules)
    {
        foreach ($rules as $rule) {
            $this->validateRule($rule, $inputName);
        }
    }
1203984
protected function validate_use_validator( array $data, array $rules ) {
		if ( empty( $rules ) ) {
			return;
		}

		$validator = new Validator( $data, $rules );

		$validator->labels(
			$this->fields->pluck( 'name', 'id' )->all()
		);

		if ( $validator->fails() ) {
			foreach ( $rules as $key => $rule ) {
				$this->add_error( $key, $validator->errors( $key ) );
			}
		}
	}
1141391
public function validate(array $input, array $ruleset)
    {
        $this->errors = array();

        foreach ($ruleset as $field => $rules) {
            #if(!array_key_exists($field, $input))
            #{
            #   continue;
            #}

            $rules = explode('|', $rules);

            if (in_array('required', $rules) || (isset($input[$field]) && trim($input[$field]) != '')) {
                foreach ($rules as $rule) {
                    $method = null;
                    $param = null;

                    if (strstr($rule, ',') !== false) {
                        // has params

                        $rule = explode(',', $rule);
                        $method = 'validate_'.$rule[0];
                        $param = $rule[1];
                        $rule = $rule[0];
                    } else {
                        $method = 'validate_'.$rule;
                    }

                    if (is_callable(array($this, $method))) {

                        $result = $this->$method($field, $input, $param);

                        if (is_array($result)) {
                            // Validation Failed

                            $this->errors[] = $result;
                        }
                    } elseif (isset($this->validation_methods[$rule])) {
                        if (isset($input[$field])) {
                            $result = call_user_func($this->validation_methods[$rule], $field, $input, $param);


                            if (!$result) {
                                // Validation Failed

                                $this->errors[] = array(
                                    'field' => $field,
                                    'value' => $input[$field],
                                    'rule' => $method,
                                    'param' => $param,
                                );
                            }
                        }
                    } else {
                        throw new Exception("Validator method '$method' does not exist.");
                    }
                }
            }
        }

        $this->compileMessage();

        return $this;
    }
1292167
public static function Rule ($rule_name, $value, $options = [], $meta = []) {
		$rule_list = static::GetValidateRuleList();
		if ($rule = $rule_list[$rule_name] ?? false) {
			return (is_callable($rule[0]) || is_array($rule[0])) ? $rule[0]($value, $options, $meta) : preg_match($rule[0], $value) === 1;
		}
		throw CoreException::RaiseSystemError('Validation not found. Rule name:%s', [$rule_name]);
	}