Exemple #1
0
 /**
  * Insert and Update validation
  * In this case, its the same for both methods
  *
  * @return bool
  */
 private function validate()
 {
     //Check nombre
     if (!$this->nombre) {
         Registry::addMessage("Debes introducir un nombre", "error", "nombre");
     } elseif (Self::getBy("nombre", $this->nombre, $this->id)) {
         Registry::addMessage("Este nombre ya está siendo utilizado", "error", "nombre");
     }
     //Check houseNumber
     Self::validateHouseNumber($this->houseNumber, $this->tipoId, $this->id);
     $tipo = new Tipo($this->tipoId);
     if (strtoupper($tipo->codigo) == "P") {
         if (!$this->programaId) {
             Registry::addMessage("Debes seleccionar un programa", "error", "programaId");
         }
         if (!$this->capitulo) {
             Registry::addMessage("Debes seleccionar un capítulo", "error", "capitulo");
         }
         if (!$this->titulo) {
             Registry::addMessage("Debes seleccionar un titulo", "error", "titulo");
         }
     }
     //TC IN/OUT
     Self::validateTc($this->tcIn, "tcIn");
     Self::validateTc($this->tcOut, "tcOut");
     //Return messages avoiding deletion
     return Registry::getMessages(true);
 }