Skip to content

Instantly share code, notes, and snippets.

@carlossalas
Created October 26, 2018 23:46
Show Gist options
  • Save carlossalas/885d9d10fc2d1182c8129076ba8bffac to your computer and use it in GitHub Desktop.
Save carlossalas/885d9d10fc2d1182c8129076ba8bffac to your computer and use it in GitHub Desktop.
CI: Form Validate
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