VALIDA_TEXTO ) { $valida = $this->_texto($valor); if($valida != true ) { $this->_mensaje['error'] .= "Campo {$campo}, debe contener solo texo%%"; } } if ($tipo == $this->VALIDA_NUM) { $valida = $this->_numero($valor); if($valida != true ) { $this->_mensaje['error'] .= "Campo {$campo}, debe contener solo Numeros%%"; } } if ($tipo == $this->VALIDA_EMAIL) { $valida = $this->_email($valor); if($valida != true ) { $this->_mensaje['error'] .= "Campo {$campo}, debe contener una cuenta valida%%"; } } } /** * getErrors() * * Regresa los errores que puedan existir * * return string $errors errores encontrados */ public function getErrors() { $this->_errors = $this->_mensaje['error']; if ($this->_errors) { //hago espli de los %% que se generan cada que escribo un mensaje de error. $errores = split("%%", $this->_errors); foreach ($errores as $error): $errors .= "

".$error."

"; endforeach; $this->_errors = $errors; } return $this->_errors; } /** * _texto * * Valida que el valor sea solo texto * * @param string $valor a validar * * @return true */ private function _texto($valor) { $expresion = true; $this->_patron = "/^[a-zA-Z ,.áéíóú�����ñ�\- 0-9]*$/"; $expresion = preg_match($this->_patron, $valor); return $expresion; } /** * _numero * * Valida que solo se contengan numeros * * @param string $valor a validar * * @return true */ private function _numero($valor) { $this->_patron = "/^[0-9]*$/"; $expresion = preg_match($this->_patron, $valor); return $expresion; } /** * _email() * * Valida que el valor sea una cuenta de correo electronico * * * @param string $valor a validar * * @return true * **/ private function _email($valor) { $this->_patron = "/^([-A-z0-9\.])+@(([-A-z0-9]+\.){1,3})([-A-z0-9]{2,4})$/"; $expresion = preg_match($this->_patron, $valor); return $expresion; } } ?>