Create a validator for $rules and $resource

@param array             $rules
@param AppliesToResource $resource (optional)

@return \Ems\Contracts\Validation\Validator|null
175347
public function make(array $rules, AppliesToResource $resource=null)
    {

        if (!$rules) {
            return null;
        }

        $validator = $this->createObject(GenericValidator::class)->setRules($rules);
        return $this->configureAndReturn($validator, $rules, $resource);
    }
1226067
public static function validate(Request $request, array $rules)
    {
        $data = $request->all();

        return Validator::make($data, $rules);
    }
238160
private function createValidator(array $data, array $rules, array $messages = [], array $customAttributes = [])
    {
        return $this->getValidatorFactory()->make($data, $rules, $messages, $customAttributes);
    }
1182528
public function validateRestResource($rest, $rest_resources_ids, $translator)
    {
        if (in_array($rest, $rest_resources_ids)) {
            return $rest;
        } else {
            throw new \InvalidArgumentException(
                sprintf(
                    $translator->trans('commands.rest.disable.messages.invalid-rest-id'),
                    $rest
                )
            );
        }
    }
36493
public function make($data, $rules)
    {
        $result = app('validator')->make($data, $rules);
        if ($result->fails()) {
            $this->errors = $result->messages()->toArray();
            return false;
        }
        $this->reset();
        return true;
    }
841287
public static function createFromResource(Resource $resource, array $options = [])
    {
        $entity = new self();

        $entity->applyResource($resource);

        return $entity;
    }
1255825
protected function performValidation(array $input, array $parsedRules, AppliesToResource $resource=null, $locale=null)
    {

        // First split rules into base rules and the custom rules of this class
        list($baseRules, $ownRules) = $this->toBaseAndOwnRules($parsedRules);

        $validation = new ValidationException();
        $validation->setRules($parsedRules);

        if ($baseRules) {
            $this->validateByBaseValidator($validation, $input, $baseRules, $resource, $locale);
        }

        if ($ownRules) {
            $this->validateByOwnMethods($validation, $input, $ownRules, $resource, $locale);
        }
        return $validation;
    }
42165
public function validate(array $input, AppliesToResource $resource=null, $locale=null)
    {

        // If a generic validator didnt have a resource until here, assign it
        if (!$this->rules && $this instanceof GenericValidatorContract && !$this->resource()) {
            $this->setResource($resource);
        }

        $rules = $this->prepareRulesForValidation($this->rules(), $input, $resource, $locale);

        $this->callBeforeListeners('validate', [$input, $rules, $resource, $locale]);

        $validation = $this->performValidation($input, $rules, $resource, $locale);

        $this->callAfterListeners('validate', [$input, $rules, $resource, $validation, $locale]);

        if (count($validation)) {
            throw $validation;
        }

        return true;
    }
773740
def validate(resource)
      rules = rules_for_resource(resource)
      rules.map { |rule| rule.validate(resource) }.compact
      # TODO:
      #   violations = rules.map { |rule| rule.validate(resource) }.compact
      #   ViolationSet.new(resource).concat(violations)
    end
1090119
public function force($value, $rule, AppliesToResource $resource=null)
    {
        if (!$this->check($value, $rule, $resource)) {
            throw new ConstraintViolationException('Value does not match constraint.');
        }

        return true;
    }
284345
public function buildRules(RulesChecker $rules)
    {
        //Uses validation rules as application rules
        $rules->add(function (Token $entity) {
            $errors = $this->getValidator('default')->errors(
                $entity->extract($this->getSchema()->columns(), true),
                $entity->isNew()
            );
            $entity->setErrors($errors);

            return empty($errors);
        });

        $rules->add($rules->existsIn(['user_id'], 'Users'));

        return $rules;
    }
476810
public function validate(array $data, array $rules, array $messages = [], array $customAttributes = [])
    {
        return $this->make($data, $rules, $messages, $customAttributes)->validate();
    }
1304714
public function detectRules(AppliesToResource $resource, $relationDepth=1)
    {
        $type = $this->typeProvider->xType($resource);
        return $this->ruleConverter->toRule($type, $relationDepth);
    }
104671
public function setValidationRules(Validator $validator, array $options = []) : Validator
    {
        $options = array_merge($this->defaultOptions, $this->fixOptions($options));

        $provider = $this->config->getProvider('validationRules');
        $validator = (new $provider($this->config))->provide($validator, $options);
        if (! $validator instanceof Validator) {
            throw new RuntimeException(
                sprintf('Provider returned value must be an instance of %s.', Validator::class)
            );
        }

        return $validator;
    }
575968
public function validate(array $values, array $rules)
    {
        // Assume no validation and result success
        $result = true;

        if (true !== $valid = $this->validateByRules($rules, $values)) {
            foreach ($valid as $componentName => $error) {
                $this->setError($error, $componentName);
            }

            // Set general form error
            $this->setError(
                [
                    'error' => 'general',
                    'info'  => [],
                ],
                Doozr_Form_Service_Constant::ERROR_IDENTIFIER_FORM
            );

            $result = false;
        }

        return $result;
    }
628408
public static function make($data, array $rules, array $customMessages = [], array $attributes = [])
    {
        return new Validator($data, $rules, $customMessages, $attributes);
    }
801335
public function runValidate(array $rules = null)
    {
        // skip validation on empty rules
        if ($rules === null) {
            return true;
        }

        $success = true;
        // list each rule as single one
        foreach ($rules as $rule) {
            // 0 = field (property) name, 1 = filter name, 2 = filter value
            if ($rule[0] === null || $rule[1] === null) {
                continue;
            }

            $propertyName = $rule[0];
            $validationRule = $rule[1];
            $validationValue = null;
            if (isset($rule[2])) {
                $validationValue = $rule[2];
            }

            // check if target field defined as array and make recursive validation
            if (Any::isArray($propertyName)) {
                $cumulateValidation = true;
                foreach ($propertyName as $attrNme) {
                    // end false condition
                    if (!$this->validateRecursive($attrNme, $validationRule, $validationValue)) {
                        $cumulateValidation = false;
                    }
                }
                // assign total
                $validate = $cumulateValidation;
            } else {
                $validate = $this->validateRecursive($propertyName, $validationRule, $validationValue);
            }

            // do not change condition on "true" check's (end-false-condition)
            if ($validate === false) {
                $success = false;
            }
        }

        return $success;
    }