Make a new validator

@param array $data
@param array $rules
@param mixed $unknown
@param mixed $custom
@return mixed
507147
public static function make(array $data, array $rules, $unknown = null, $custom = [])
  {
    $factory = new ValidatorFactory();

    if (is_array($unknown) && count($unknown) > 0) {
      $custom = $unknown;
    }

    $response = $factory->make($data, $rules, $custom);

    if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
      strtoupper($_SERVER['HTTP_X_REQUESTED_WITH']) === 'XMLHTTPREQUEST' &&
      $response->fails()) {
        return Rest::response()
                    ->json($response->errors()->toArray(), 422);

        die();
    }

    return $response;
  }
869370
public function validate(RequestModel $request, array $rules, array $messages = [], array $customAttributes = [])
    {
        if ($request instanceof RequestModelCollection) {
            $request->map(function (RequestModel $requestModel) use ($rules) {
                $this->validate($requestModel, $rules);
            });
            return;
        }

        $validator = $this->getValidationFactory()->make($request->all(), $rules, $messages, $customAttributes);

        if ($validator->fails()) {
            $this->throwValidationException($request->request(), $validator);
        }
    }
307572
protected function validate(array $rules, $values = null, array $customAttrs = [])
    {
        // Se os valores forem nulos, buscar no request
        if (is_null($values)) {
            $values = request()->all();
        }

        // Validar valores pela regra
        return Validator::validate($values, $rules, $customAttrs);
    }
934210
public function validate( $data, array $rules = [] )
	{
		$this->normalizeData( $data );
		$this->setRules( $rules );

		foreach( $this->rules as $attribute => $rules ) {
			foreach( $rules as $rule ) {
				$this->validateAttribute( $rule, $attribute );

				if( $this->shouldStopValidating( $attribute ))break;
			}
		}

		return $this->errors;
	}
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 ) );
			}
		}
	}
308072
public function updateUniques(array $rules = array(),
        array $customMessages = array(),
        array $options = array(),
        Closure $beforeSave = null,
        Closure $afterSave = null
    ) {
        $rules = $this->buildUniqueExclusionRules($rules);
        
        return $this->save($rules, $customMessages, $options, $beforeSave, $afterSave);
    }
416585
protected final function validateNewData(array $data = null) {
		if ($data === null && isset($this->_formData)) {
			$data = $this->_formData;
		}
		if ($this->rules) {
			return $this->validateData($this->rules, $data);
		}

		return true;
	}
354946
public function sanitize(array $data, array $rules = [], array $filters = [])
    {
        $this->setRules($rules);
        $this->setFilters($filters);

        foreach ($data as $name => $value) {
            $data[$name] = $this->sanitizeAttribute($name, $value);
        }

        return $data;
    }
38401
public static function create(array $rules, array $data = null, bool $validateAndThrowException = true): Validator
    {
        $validator = new static($rules, $data);

        if ($validateAndThrowException) {
            if (!$validator->isAllValid()) {
                $exception = new InvalidDataException('Validator exception');
                $exception->setValidator($validator);
                throw $exception;
            }
        }

        return $validator;
    }
509755
private function tryValidateData(
        array $data,
        array $rules,
        Closure $validationFailed,
        array $messages = [],
        array $customAttributes = []
    ) {
        $validator = $this->createValidator($data, $rules, $messages, $customAttributes);

        if ($validator->fails()) {
            call_user_func($validationFailed, $validator->errors()->getMessages());
        }
    }
1259040
public function validateDataWithRules(array $data, array $validateRules, array $validateMessages = [], array $parametricConverter = [])
    {
        foreach ($validateRules as $key => $rules) {
            $value = array_key_exists($key, $data) ? $data[$key] : null;

            if (array_key_exists('nullable', $rules) && $rules['nullable'] && is_null($value)) {
                continue;
            }

            unset($rules['nullable']);

            $defaultParametricConverter = (method_exists($this, 'getParametricConverter') && is_array($this->getParametricConverter())) ? $this->getParametricConverter() : [];
            $parametricConverter = array_merge($defaultParametricConverter, $parametricConverter);
            $parameter = (array_key_exists($key, $parametricConverter)) ? $parametricConverter[$key] : $key;

            foreach ($rules as $ruleName => $ruleParameter) {
                if ($ruleName === 'callback') {
                    if (!is_callable($ruleParameter)) {
                        throw new BadMethodCallException('The reference of rule named `callback` must be a valid callable. You provided ' . $this->getValueDescription($ruleParameter) . '.');
                    }

                    call_user_func($ruleParameter, $value, InvalidRequestException::class);
                } else {
                    $method = 'check'.ucfirst(Helper::camelCase($ruleName));

                    if (!method_exists($this, $method)) {
                        throw new BadMethodCallException('Call to undefined the ' .get_class($this). '::' .$method. '() validator that associated with the `' .$ruleName. '` rule');
                    }

                    if (!$this->$method($value, $ruleParameter)) {
                        $message = isset($validateMessages[$key][$ruleName]) ? $validateMessages[$key][$ruleName] : null;

                        throw new InvalidRequestException($this->formatMessage($parameter, $ruleName, $ruleParameter, $message));
                    }
                }
            }
        }
    }
544223
protected function createValidator(array $data, array $rules)
    {
        /** @var Factory $factory */
        $factory   = app('validator');
        $validator = $factory->make($data, $rules);

        return $validator;
    }
376429
protected function executeValidation(array $data)
    {
        if ($method = array_get($this->scenario, 'on')) {
            call_user_func_array([$this, $method], $this->scenario['arguments']);
        }

        $rules = $this->getBoundRules();

        $messages = $this->getMessages();

        $customAttributes = $this->getCustomAttributes();

        $validator = $this->factory->make($data, $rules, $messages, $customAttributes);

        return $validator->errors();
    }
838128
public static function present(Validator $validator, $data, $pattern, $rule)
    {
        if (ArrDots::has($data, $pattern, $validator::WILD)) {
            return;
        }

        $validator->addError($pattern, $rule);
    }
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;
    }
578783
public function make(array $rules, AppliesToResource $resource=null)
    {

        if (!$resource) {
            return null;
        }

        $rules = array_merge($this->detectRules($resource), $rules);

        return $this->createObject(GenericValidator::class)->setRules($rules);

    }
184514
public function validate($data, array $rules, $context = null): ValidatorInterface
    {
        return new Validator($data, $rules, $context, $this);
    }