Пример #1
0
 /**
  * Método encargado de validar datos
  * @param  Array $array Datos a validar
  * @return Boolean      true = si los datos son validos, false = si son invalidos
  */
 public static function validar($array)
 {
     // Validación de la clave
     if (isset($array['clave'])) {
         if (($erro = Validaciones::validarPassLogin($array["clave"])) !== true) {
             Session::addArray('feedback_negative', $erro);
         }
     } else {
         Session::add('feedback_negative', 'No se ha indicado la clave');
     }
     // Validación del email
     if (isset($array['email'])) {
         if (($erro = Validaciones::validarEmail($array["email"])) !== true) {
             Session::addArray('feedback_negative', $erro);
         }
     } else {
         Session::add('feedback_negative', 'No se ha indicado el email');
     }
     // Si hay errores devolvemos false
     if (Session::get('feedback_negative')) {
         return false;
     }
     // Si no hay errores devolvemos true
     return true;
 }
Пример #2
0
 public static function validarEntradaLogin()
 {
     $errores = [];
     if (!$_POST) {
         $errores['generic'][] = "No he recibido datos";
         return Validaciones::resultado($errores);
     }
     $_POST = Validaciones::sanearEntrada($_POST);
     if (strpos($_POST['nick'], "@") === false) {
         if (($err = Validaciones::validarNick($_POST['nick'])) !== true) {
             $errores['nick'] = $err;
         }
     } else {
         if (($err = Validaciones::validarEmail($_POST['nick'])) !== true) {
             $errores['nick'] = $err;
         }
     }
     if (($err = Validaciones::validarPassLogin($_POST['passwd'])) !== true) {
         $errores['passwd'] = $err;
     }
     return Validaciones::resultado($errores);
 }