Skip to content

Commit

Permalink
Fix no data return for validation
Browse files Browse the repository at this point in the history
  • Loading branch information
yidas committed Apr 8, 2019
1 parent d6258b4 commit 0301713
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Base Model
*
* @author Nick Tsai <[email protected]>
* @version 2.16.5
* @version 2.16.6
* @see https://github.com/yidas/codeigniter-model
*/
class Model extends \CI_Model implements \ArrayAccess
Expand Down Expand Up @@ -352,10 +352,14 @@ public function validate($attributes=[], $returnData=false)
$rules = $newRules;
}

// CodeIgniter form_validation doesn't work with empty array data
if (empty($rules) || empty($data))
// Check if has rules
if (empty($rules))
return ($returnData) ? $data : true;

// CodeIgniter form_validation doesn't work with empty array data
if (empty($data))
return false;

// Load CodeIgniter form_validation library for yidas/model namespace, which has no effect on common one
get_instance()->load->library('form_validation', null, 'yidas_model_form_validation');
// Get CodeIgniter validator
Expand Down

0 comments on commit 0301713

Please sign in to comment.