Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
- /***** Validação *****/
- function validateBanda($ajax = true) {
- // Mensagens
- $msgVazio = 'Ops, o campo de %s está vazio!';
- $msgSelect = 'Você precisa selecionar uma opção no campo %s!';
- $msgLogin = 'O login escolhido já existe!';
- $msgSenha = 'Sua senha não pode ser igual ao seu login.';
- $msgResenha = 'A confirmação da sua senha não confere!';
- $msgEmail = 'E-mail inválido.';
- $msgFoto = 'Ops, houve um erro ao enviar sua foto!';
- $msgTermos = 'Você precisa aceitar os termos antes de continuar.';
- $msgBoxes = 'Selecione ao menos uma opção para os %s.';
- $this->form_validation->set_message('required', $msgVazio);
- $this->form_validation->set_message('is_natural_no_zero', $msgSelect);
- $this->form_validation->set_message('matches', $msgResenha);
- $this->form_validation->set_message('_userCheck', $msgLogin);
- $this->form_validation->set_message('_boxesCheck', $msgBoxes);
- $this->form_validation->set_message('_termosCheck', $msgTermos);
- $this->form_validation->set_message('_nomatches', $msgSenha);
- // Regras
- $fields = array('geLogin', 'geSenha', 'geResenha', 'geEmail', 'inNome',
- 'inEstado', 'inCidade', 'inBairro', 'muRelease',
- 'muGenero1', 'muGenero1', 'muGenero1', 'muObjetivos',
- 'muTempo', 'iaIntegrantes', 'mpMusicos', 'ctContato', 'frTermos');
- $this->form_validation->set_rules('geLogin', 'Login', 'trim|required|min_length[5]|max_length[20]|callback__userCheck');
- $this->form_validation->set_rules('geSenha', 'Senha', 'required|matches[geResenha]|callback__nomatches[geLogin]');
- $this->form_validation->set_rules('geResenha', 'Confirmação', 'required');
- $this->form_validation->set_rules('geEmail', 'E-mail', 'required|valid_email');
- $this->form_validation->set_rules('inNome', 'Nome', 'required');
- $this->form_validation->set_rules('inEstado', 'Estado', 'is_natural_no_zero');
- $this->form_validation->set_rules('inCidade', 'Cidade', 'is_natural_no_zero');
- $this->form_validation->set_rules('inBairro', 'Bairro', 'trim|required');
- $this->form_validation->set_rules('muRelease', 'Release', 'required');
- $this->form_validation->set_rules('muGenero1', 'Gênero 1', 'is_natural_no_zero');
- $this->form_validation->set_rules('muObjetivos', 'Objetivos', 'is_natural_no_zero');
- $this->form_validation->set_rules('muTempo', 'Experiência', 'required|is_natural');
- $this->form_validation->set_rules('iaIntegrantes', 'Integrantes', 'callback__boxesCheck');
- $this->form_validation->set_rules('mpMusicos', 'Músicos', 'callback__boxesCheck');
- $this->form_validation->set_rules('ctContato', 'Contatos', 'required');
- $this->form_validation->set_rules('frTermos', 'Termos', 'callback__termosCheck');
- if ($this->form_validation->run()) {
- }
- else {
- // echo $this->form_validation->error_string();
- foreach ($fields as $field) {
- $error[$field] = form_error($field);
- }
- return $error;
- }
- }
- /***** Funções validação *****/
- function _userCheck($login) {
- return !$this->UsuariosModel->userExists($login);
- }
- function _boxesCheck($campo) {
- return (is_array($campo) && count($campo) > 0);
- }
- function _termosCheck($termos) {
- return $termos == 'on';
- }
- function _nomatches($a, $b) {
- return !$this->form_validation->matches($a, $b);
- }
- ?>
Add Comment
Please, Sign In to add comment