From 759ce15d21007297f63f69d9753889e74a37199b Mon Sep 17 00:00:00 2001 From: Harpreet Bhatia Date: Fri, 12 Feb 2016 15:27:37 +0530 Subject: [PATCH] Updated checks for less than and greater than example: I dont want field name to be less then 1. ```php $prop->validation->num_lt(array("field_name"), 1, "required"); if (!$prop->validation->is_valid()){ $prop->helper->sendResponse(400, $prop->validation->get_error()); } ``` --- application/libraries/Validation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/libraries/Validation.php b/application/libraries/Validation.php index 5db1b92..e7fd6b1 100755 --- a/application/libraries/Validation.php +++ b/application/libraries/Validation.php @@ -488,7 +488,7 @@ public function num_gt($fields, $num, $err_msg = '') { foreach ($fields as $v) { $this->num($v, $err_msg); if ($this->is_valid()) { - if ($this->data[$v] < $num) { + if ((int)$this->data[$v] > $num) { $this->_error($err_msg, $v); } } @@ -512,7 +512,7 @@ public function num_lt($fields, $num, $err_msg = '') { foreach ($fields as $v) { $this->num($v, $err_msg); if ($this->is_valid()) { - if ($this->data[$v] > $num) { + if ((int)$this->data[$v] < $num) { $this->_error($err_msg, $v); } }