Ejemplo n.º 1
0
 function validar_estado()
 {
     $padre = parent::validar_estado();
     if ($padre !== true) {
         return $padre;
     }
     if ($this->estado == '' || $this->_desactivar_validacion) {
         return true;
     }
     if ($this->confirma_excepcion_validacion()) {
         return true;
     }
     return self::validar_cuit($this->estado);
 }
Ejemplo n.º 2
0
 /**
  * Valida que cumpla con la lista de extensiones válidas definidas.
  * También chequea los {@link http://www.php.net/manual/en/features.file-upload.errors.php mensajes de error de upload} de php
  * @return unknown
  */
 function validar_estado()
 {
     $padre = parent::validar_estado();
     if ($padre !== true) {
         return $padre;
     }
     if ($this->archivo_subido) {
         $id = $this->estado['error'];
         switch ($id) {
             case UPLOAD_ERR_OK:
                 break;
             case UPLOAD_ERR_INI_SIZE:
                 return "Se supero el tamaño máximo del archivo.";
             case UPLOAD_ERR_FORM_SIZE:
                 return "Se supero el limite expresado en el FORM";
             case UPLOAD_ERR_NO_FILE:
                 //Este caso lo maneja el obligatorio
                 $this->archivo_subido = false;
                 break;
             case UPLOAD_ERR_CANT_WRITE:
                 return "No tiene permisos sobre la carpeta de upload";
             default:
                 return "Ha ocurrido un error cargando el archivo ({$id})";
         }
         if (!$this->solo_lectura_modificacion && isset($this->extensiones_validas) && $this->archivo_subido && !$this->es_archivo_vacio()) {
             $rep = $_FILES[$this->id_form]['name'];
             $ext = substr($rep, strrpos($rep, '.') + 1);
             if (!in_array(strtolower($ext), $this->extensiones_validas)) {
                 $extensiones = implode(', ', $this->extensiones_validas);
                 $this->archivo_subido = false;
                 $this->estado = null;
                 return "No esta permitido subir este tipo de archivo. Solo se permiten extensiones {$extensiones}";
             }
         }
     }
     return true;
 }
Ejemplo n.º 3
0
 function validar_estado()
 {
     $padre = parent::validar_estado();
     if ($padre !== true) {
         return $padre;
     }
     //Si el ef tiene estado realizo chequeos
     if ($this->tiene_estado() && $this->estado != '') {
         //Hago el chequeo x expresion regular si existiera
         if (isset($this->expreg) && !preg_match($this->expreg, $this->estado)) {
             return 'No es válido';
         }
         //Evaluo si se supera el maximo de caracteres permitido
         if (isset($this->maximo) && !is_null($this->maximo) && strlen($this->estado) > $this->maximo) {
             if (!isset(self::$callback_errores_validacion)) {
                 return "Supera el ancho máximo {$this->maximo}";
             } else {
                 return self::$callback_errores_validacion->editable_maximo($this, $this->maximo, $this->estado);
             }
         }
     }
     return true;
 }
Ejemplo n.º 4
0
 /**
  * La validación verifica si se cumple con la cantidad mínima y máxima
  */
 function validar_estado()
 {
     $padre = parent::validar_estado();
     if ($padre !== true) {
         return $padre;
     }
     if ($this->confirma_excepcion_validacion()) {
         return true;
     }
     if (isset($this->cant_minima)) {
         if (count($this->estado) < $this->cant_minima) {
             $elemento = $this->cant_minima == 1 ? "un elemento" : "{$this->cant_minima} elementos";
             return "Seleccione al menos {$elemento}.";
         }
     }
     if (isset($this->cant_maxima)) {
         if (count($this->estado) > $this->cant_maxima) {
             $elemento = $this->cant_maxima == 1 ? "un elemento" : "{$this->cant_maxima} elementos";
             return "No puede seleccionar más de {$elemento}.";
         }
     }
     return true;
 }