Skip to content

Commit

Permalink
Added unique username and unique email validators to custom validatio…
Browse files Browse the repository at this point in the history
…n library, so they actually run...
  • Loading branch information
brockf authored Sep 11, 2017
1 parent ee7e225 commit ecdbcee
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions app/libraries/MY_Form_validation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Form_validation extends CI_Form_validation {
public function __construct() {
parent::__construct();

$this->CI =& get_instance();
}

function unique_email($email) {
$this->CI->load->model('users/user_model');
if ($this->CI->user_model->unique_email($email)) {
return TRUE;
}
else {
$this->CI->form_validation->set_message('unique_email', 'The Email you have selected is unavailable.');
return FALSE;
}
}

function unique_username($username) {
$this->CI->load->model('users/user_model');
if ($this->CI->user_model->unique_username($username)) {
return TRUE;
}
else {
$this->CI->form_validation->set_message('unique_username', 'The Username you have selected is unavailable.');
return FALSE;
}
}
}

0 comments on commit ecdbcee

Please sign in to comment.