public function isValid($Validation_data) { $errors = []; foreach ($Validation_data as $name => $value) { if (isset($_REQUEST[$name])) { $exploded = explode(':', $value); switch ($exploded[0]) { case 'min': $min = $exploded[1]; if (Valid::string()->length(3)->validate($_REQUEST[$name]) == false) { $errors[] = "{$name} must be {$min} caracters long"; } break; case 'email': if (Valid::email()->validate($_REQUEST[$name]) == false) { $errors[] = $name . ' is not a valid email'; } break; case 'equalsTo': $field = $exploded[1]; if (!Valid::equals($name)->validate($field)) { $errors[] = $name . " must be equal to " . $field; } break; } } } return $errors; }