Created
October 26, 2018 23:46
-
-
Save carlossalas/885d9d10fc2d1182c8129076ba8bffac to your computer and use it in GitHub Desktop.
CI: Form Validate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function validate() | |
{ | |
$this->load->library('form_validation'); | |
$validation_rules = [ | |
[ | |
'field' => 'email', | |
'rules' => 'trim|required|valid_email' | |
], | |
[ | |
'field' => 'password', | |
'rules' => 'trim|required' | |
] | |
]; | |
$this->form_validation->set_rules($validation_rules); | |
if($this->form_validation->run()) return TRUE; | |
else throw new Exception('error_form_validation'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment