Validates the supplied data against the options rules.

@param array $data
@param array $rules
@param array $messages
@param mixed
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;
    }
1175010
public function rules($rules = null, $messages = [])
    {
        if ($rules instanceof \Closure) {
            $this->rules = $rules;
        }

        if (is_string($rules)) {
            $rules = array_filter(explode('|', "{$this->rules}|$rules"));

            $this->rules = implode('|', $rules);
        }

        $this->validationMessages = $messages;

        return $this;
    }
1113049
public function make($data, $rules, $messages=[], $clean = true) {
      // parametros de los roles
      $param = [];
      $temp  = "";
      if($clean)
         $this->fails = null;

      foreach ($rules as $field => $rule) {
      // foreach ($data as $field => $value) {

         if(!isset($rules[$field])) continue;

         $value = @$data[$field];

         if(!is_array($value)) $value = trim($value);

         if(!is_array($rules[$field])) $rules[$field] = explode("|", $rules[$field]);

         foreach ($rules[$field] as $key_rol => $rol) {
            $rol = trim($rol);

            if (preg_match("/:/", $rol)) {
               if(preg_match("/regex/", $rol)) {
                  $temp_rol = explode(":", $rol);
                  $rol      = ($temp_rol[0]);
                  unset($temp_rol[0]);
                  $param[0]    = implode(':', @$temp_rol);
               } else{
                  $temp_rol = explode(":", $rol);
                  $rol      = ($temp_rol[0]);
                  unset($temp_rol[0]);
                  $param    = explode(",", implode(':', @$temp_rol));
               }
            }
            switch ($rol) {
               case 'accepted':
                  break;
               case 'active_url':
                  break;
               case 'after':
                  break;
               case 'alpha':
                  if ($value!='') {
                     // ASCII lATIN1
                     if (!preg_match('/^[a-zA-Zá-üÁ-Ü\s]*$/', $value)) {
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'alpha_dash':
                  if ($value!='') {
                     // ASCII lATIN1
                     if (!preg_match("/^[0-9a-zA-Zá-üÁ-Ü\s_\-\.,\(\)]*$/", $value)) {
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'alpha_num':
                  if ($value!='') {
                     // ASCII lATIN1
                     if (!preg_match("/^[0-9a-zA-Zá-üÁ-Ü\s\.]*$/", $value)) {
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'array':
                  if ($value!='') {
                     if (!is_array($value)) {
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'before':break;
               case 'between':
                  //    "numeric"            "file"            "string"          "array"
                  if (@$param[0]=='' || !is_numeric(@$param[0]) || !is_numeric(@$param[1])) throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);
                  if ($value!='') {
                     $len = $value;
                     if (is_array($value)) {
                        $len = count($value);
                     }elseif (!is_numeric($value)) {
                        $len = strlen($value);
                     }

                     if ($len < @$param[0]) {
                        $fail_max = true;
                     }

                     if ($len > @$param[1]) {
                        $fail_min = true;
                     }

                     if (!count($param) || @$fail_max || @$fail_min ) {
                        if (is_array($value)) {
                           $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol]['array'])));
                        }elseif (!is_numeric($value)) {
                           $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol]['string'])));
                        }else{
                           $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol]['numeric'])));
                        }

                        $temp = str_replace(":min", @$param[0]?@$param[0]:0, $temp);
                        $temp = str_replace(":max", @$param[1]?@$param[1]:0, $temp);
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'confirmed':break;
               case 'date':break;
               case 'date_format':
                  if (@$param[0]=='') throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);

                  if ($value!='') {
                     $format = date_parse_from_format(@$param[0], $value);

                     if ($format['error_count']) {

                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":format", @$param[0]?@$param[0]:0, $temp);
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'different':
                  if (@$param[0]=='') throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);

                  $d = [
                     $field => $value,
                  ];
                  $r = [
                     $field => implode('|', $rules[@$param[0]]),
                  ];

                  $Validator = new Validator;
                  $v = $Validator->make($d,$r,@$messages);

                  if (count($v->fails) || strtolower($value)==strtolower($data[@$param[0]])) {
                     if (count($v->fails)) {
                        $this->fails["messages"][$field]   = $v->fails["messages"][$field];
                        $this->fails["failed"]  [$field]   = $v->fails["failed"]  [$field];
                     }else{
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":other", @$param[0], $temp);
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'digits':
                  if (!is_numeric(@$param[0])) throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);
                  if ($value!='') {
                     if (!preg_match("/^[0-9]*$/", $value) || !count($param) || strlen($value) != @$param[0]) {
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":digits",    @$param[0]?@$param[0]:0, $temp);
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'digits_between':
                  if (!is_numeric(@$param[0]) || !is_numeric(@$param[1])) throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);
                  if ($value!='') {
                     $len = strlen($value);

                     if ($len < @$param[0]) $fail_max = true;

                     if ($len > @$param[1]) $fail_min = true;

                     if (@$fail_max || @$fail_min ) {

                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));

                        $temp = str_replace(":min", @$param[0]?@$param[0]:0, $temp);
                        $temp = str_replace(":max", @$param[1]?@$param[1]:0, $temp);
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'email':
                  if ($value!='') {
                     $value=filter_var($value, FILTER_SANITIZE_EMAIL);
                     if(!filter_var($value, FILTER_VALIDATE_EMAIL)) {
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'exists':break;
               case 'image':
                  if ($value!='') {
                     if (!preg_match("/.*(\.jpg)|(\.jpeg)|(\.png)|(\.bmp)|(\.gif)$/", $value)) {
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'in':
                  if (@$param[0]=='') throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);
                  if ($value!='') {
                     if (!is_numeric(array_search(strtolower($value), array_map( function ($v){return strtolower($v);}, $param)))) {

                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":values", implode(',', @$param), $temp);
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'integer':
                  if ($value!='') {
                     if (!preg_match("/^[0-9]*$/", $value)) {
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'ip':
                  if ($value!='') {
                     if (!preg_match("/^([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}$/", $value)) {
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'max':
                  //    "numeric"            "file"            "string"          "array"
                  if (!is_numeric(@$param[0])) throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);
                  if ($value!='') {
                     $len = $value;
                     if (is_array($value)) {
                        $len = count($value);
                     }elseif (is_string($value)) {
                        $len = strlen($value);
                     }

                     if (!count($param) || ($len > @$param[0])) {
                        if (is_array($value)) {
                           $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol]['array'])));
                        }elseif (is_string($value)) {
                           $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol]['string'])));
                        }else{
                           $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol]['numeric'])));
                        }

                        $temp = str_replace(":max"      , @$param[0]?@$param[0]:0, $temp);
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'mimes':
                  if (@$param[0]=='') throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);

                  if ($value!='') {
                     $param = implode('|', $param);

                     if (!preg_match("/.*".$param."$/", $value)) {
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":values", str_replace('|', ',', @$param), $temp);
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'min':
                  //    "numeric"            "file"            "string"          "array"
                  if (!is_numeric(@$param[0])) throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);
                  if ($value!='') {
                     $len = $value;
                     if (is_array($value)) {
                        $len = count($value);
                     }elseif (is_string($value)) {
                        $len = strlen($value);
                     }
                     
                     if (!count($param) || ($len < @$param[0])) {
                        if (is_array($value)) {
                           $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol]['array'])));
                        }elseif (is_string($value)) {
                           $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol]['string'])));
                        }else{
                           $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol]['numeric'])));
                        }

                        $temp = str_replace(":min"      , @$param[0]?@$param[0]:0, $temp);
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'not_in':
                  if (!@$param[0]) throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);
                  if ($value!='') {
                     if (is_numeric(array_search(strtolower($value), array_map( function ($v){return strtolower($v);}, $param)))) {
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":values", implode(',', @$param), $temp);
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'numeric':
                  if ($value!='') {
                     if ( !is_numeric( str_replace( ',','.', $value ) ) ) {
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'regex':
                  if (@$param[0]=='') throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);
                  if ($value!='') {
                     if (!preg_match($param[0], $value)) {
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'required':
                  if ($value==="" || $value===false || $value===null) {
                     $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                     $temp = str_replace(":data", $value, $temp);

                     $this->fails["messages"][$field][] = $temp;
                     $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                  }
                  break;
               case 'required_if':
                  # syntax: required_if:field1,value1,field2,value2,...
                  if (@$param[0]=='') throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);
                  if ((count(@$param)%2)!=0) throw new Exception(" Los valores del parametro del rol {$rol} deben ser de campo-valor. Ej. field1,value1,field2,value2,... ", 1);
                  $str = [];
                  foreach($param as $key => $v) {
                     if(($key%2)==0)
                        $d = $data[$v];
                     else
                        $str[] = "( '".trim($d)."' == '".trim($v)."' )";
                  }

                  $eval = null;
                  eval('$eval = '.join('||', $str).';');

                  if ( ($value==="" || $value===false || $value===null) && $eval ) {
                     $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                     $temp = str_replace(":other", @$param[0], $temp);
                     $temp = str_replace(":values", @$param[1], $temp);
                     $temp = str_replace(":data", $value, $temp);

                     $this->fails["messages"][$field][] = $temp;
                     $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                  }
                  break;
               case 'required_less':
                  # syntax: required_less:field1,value1,field2,value2,...
                  if (@$param[0]=='') throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);
                  if ((count(@$param)%2)!=0) throw new Exception(" Los valores del parametro del rol {$rol} deben ser de campo-valor. Ej. field1,value1,field2,value2,... ", 1);
                  $str = [];
                  foreach($param as $key => $v) {
                     if(($key%2)==0)
                        $d = $data[$v];
                     else
                        $str[] = "( '".trim($d)."' != '".trim($v)."' )";
                  }

                  $eval = null;
                  eval('$eval = '.join('||', $str).';');

                  if ( ($value==="" || $value===false || $value===null) && $eval ) {
                     $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                     $temp = str_replace(":other", @$param[0], $temp);
                     $temp = str_replace(":values", @$param[1], $temp);
                     $temp = str_replace(":data", $value, $temp);

                     $this->fails["messages"][$field][] = $temp;
                     $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                  }
                  break;
               case 'required_with':
                  if (@$param[0]=='') throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);
                  if (!is_numeric(array_search(strtolower($value), array_map( function ($v){return strtolower($v);}, $param)))) {
                     $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                     $temp = str_replace(":values", implode(',', @$param), $temp);
                     $temp = str_replace(":data", $value, $temp);

                     $this->fails["messages"][$field][] = $temp;
                     $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                  }
                  break;
               case 'required_without':
                  if (@$param[0]=='') throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);
                  if (is_numeric(array_search(strtolower($value), array_map( function ($v){return strtolower($v);}, $param)))) {
                     $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                     $temp = str_replace(":values", implode(',', @$param), $temp);
                     $temp = str_replace(":data", $value, $temp);

                     $this->fails["messages"][$field][] = $temp;
                     $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                  }
                  break;
               case 'same':
                  if (@$param[0]=='') throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);

                  $d = [$field => $value,];
                  $r = [$field => implode('|', $rules[@$param[0]]),];

                  $Validator = new Validator;
                  $v = $Validator->make($d,$r,$messages);

                  if (count($v->fails) || strtolower($value)!=strtolower($data[@$param[0]])) {
                     if (count($v->fails)) {
                        $this->fails["messages"][$field]   = $v->fails["messages"][$field];
                        $this->fails["failed"]  [$field]   = $v->fails["failed"]  [$field];
                     }else{
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":other", @$param[0], $temp);
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'size':
                  //    "numeric"            "file"            "string"          "array"
                  if (@$param[0]=='' || !is_numeric(@$param[0])) throw new Exception(" El parametro del rol {$rol} es incorrecto ", 1);
                  if ($value!='') {
                     $len = $value;
                     if (is_array($value)) {
                        $len = count($value);
                     }elseif (!is_numeric($value)) {
                        $len = strlen($value);
                     }

                     if (!count($param) || ($len) != (@$param[0])) {
                        if (is_array($value)) {
                           $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol]['array'])));
                        }elseif (!is_numeric($value)) {
                           $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol]['string'])));
                        }else{
                           $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol]['numeric'])));
                        }

                        $temp = str_replace(":size", @$param[0]?@$param[0]:0, $temp);
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'text':
                  if ($value!='') {
                     // ASCII lATIN1
                     // if ($value) {
                     //    $this->fails["messages"][$field][] = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                     //    $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     // }
                  }
                  break;
               case 'unique':break;
               case 'url':
                  if ($value!='') {
                     if (!filter_var($value, FILTER_VALIDATE_URL)) {
                        $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                        $temp = str_replace(":data", $value, $temp);

                        $this->fails["messages"][$field][] = $temp;
                        $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                     }
                  }
                  break;
               case 'sqlStatement':
                  if ($value!='') {
                     $strings = explode(' ',$value);
                     foreach($strings as $key => $string) {
                        if(in_array(strtolower($string), $this->sqlStatement)) {
                           $temp = str_replace(":attribute", $field, (@$messages[$rol] ? @$messages[$rol] : (@$messages[$field] ? @$messages[$field] : @$this->messages[$rol])));
                           $temp = str_replace(":values", strtoupper($string), $temp);
                           $temp = str_replace(":data", $value, $temp);

                           $this->fails["messages"][$field][] = $temp;
                           $this->fails["failed"]  [$field][] = $rules[$field][$key_rol];
                           break;
                        }
                     }
                  }
                  break;
               default:
                  $error = false;
                  $message = null;
                  if(@$this->roles_created[$rol] instanceof closure || gettype(@$this->roles_created[$rol])==='object') { // 'rol' => function();
                     $error = $this->roles_created[$rol]($value, $param, $data, $this);
                  }
                  elseif(@$this->roles_created[$rol][0] instanceof closure || gettype(@$this->roles_created[$rol][0])==='object') { // 'rol' => [function()];
                     $error = $this->roles_created[$rol][0]($value, $param, $data, $this);
                  }
                  elseif(is_string(@$this->roles_created[$rol][0]) && (@$this->roles_created[$rol][1] instanceof closure || gettype(@$this->roles_created[$rol][1])==='object')) { // 'rol' => ['message',function()];
                     $message = $this->roles_created[$rol][0];
                     $error = $this->roles_created[$rol][1]($value, $param, $data, $this);
                  }

                  if(is_array($error)) {
                     $temp_error = $error;
                     $error   = @$temp_error['error'];
                     if(@$temp_error['message'])
                        $message = @$temp_error['message'];
                  }
                  if($error) {
                     $temp_value = is_array($value) ? 'Array' : $value;
                     $message = $message ? $message : @$messages[$rol];
                     $temp = str_replace(":attribute", $field, $message);
                     $temp = str_replace(":values", implode(',', @$param), $temp);
                     $temp = str_replace(":data", $temp_value, $temp);

                     $this->fails["messages"][$field][] = $temp;
                     $this->fails["failed"]  [$field][] = $rol;
                  }

                  break;
            }
         }
      }

      return $this;
   }
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;
    }
507146
public function validate(array $constraints, $data, $prettyName = 'This value')
    {
        if (gettype($data) == 'array') {
            $this->validateSequentialArray($data, $prettyName);
        } else {
            $message = $constraints['message'] ?? '%s must be a sequential array';
            throw new DataValidationException(sprintf($message, $prettyName));
        }

        parent::validate($constraints, $data, $prettyName);
    }
539889
protected function validate(array &$data)
    {
        $this->validateVersion();
        $this->validateExtensions();
        $this->validateIni();
        $data = array_merge($data, ['messages' => $this->messages]);
        return $data;
    }
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;
    }
544223
protected function createValidator(array $data, array $rules)
    {
        /** @var Factory $factory */
        $factory   = app('validator');
        $validator = $factory->make($data, $rules);

        return $validator;
    }
572641
protected function resolve(array $data, array $rules, array $messages, array $customAttributes)
    {
        if (is_null($this->resolver)) {
            return new Validator($this->translator, $data, $rules, $messages, $customAttributes);
        } else {
            return call_user_func($this->resolver, $this->translator, $data, $rules, $messages, $customAttributes);
        }
    }
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();
    }
302407
private function prepareRecord(array $data, array $rules, array $messages)
    {
        // Reset error bag
        $this->errors = new MessageBag;

        // Capture data
        $this->setDataset($data);
        $this->setRuleset($rules);
        $this->setMessageset($messages);

        // Fill model
        $this->fillModel();
    }
598873
public function validate(?array $data): array
    {
        $errorMsgs = [];
        foreach ($this->fieldsRuleProperties as $fieldName => $ruleProperties) {
            // Get value to validate
            if (isset($data[$fieldName])) {
                $value = $data[$fieldName];

                // Trim all values unless explicitly set to not
                if (is_string($value) && (!isset($ruleProperties['trim']) || $ruleProperties['trim'] === true)) {
                    $value = trim($value);
                }
                // allow a nullable value to be added as validated data
            } elseif (!empty($ruleProperties['nullable']) && array_key_exists($fieldName, $data)) {
                $value = null;
                // Don't validate empty values that are not set and not required
            } elseif (empty($ruleProperties['required']) && empty($ruleProperties['nonEmpty'])) {
                continue;
            } else {
                // Empty string as default (not null because that adds complexity to checks)
                $value = '';
            }

            // Validate value against each of the fields' rules
            $errorMsg = $this->validateValue($value, $ruleProperties);

            // If field has any error messages, add to error array, otherwise add value to validated data
            if ($errorMsg) {
                $errorMsgs[$fieldName] = $errorMsg;
            } else {
                $this->validatedData[$fieldName] = $value;
            }
        }

        return $errorMsgs;
    }
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
        );
    }
1325422
protected function validate($input, array &$messages)
    {
        if (!preg_match(ColourStringParser::REGEX_RGBA, $input)) {
            $messages[] = new Message(self::MESSAGE);
        }
    }
1351448
public function validate(array $constraints, $data, $prettyName = 'This value')
    {
        if (!is_bool($data)) {
            $message = $constraints['message'] ?? '%s must be boolean';
            throw new DataValidationException(sprintf($message, $prettyName));
        }

        parent::validate($constraints, $data, $prettyName);
    }
846357
protected function setup_validation($data)
    {
        $this->validation = new Validation($data, $this->rules(), $this->messages());

        if (!empty($this->aliases())) {
            $this->set_aliases($this->aliases());
        }
    }
1330108
protected function _validate($data, $options, $isNew)
    {
        $errors = parent::_validate($data, $options, $isNew);
        if (!empty($errors)) {
            Log::write('error', json_encode($errors));
        }
        return $errors;
    }