From ca2ec1cfb9ebb917943882decb7927f7fdc715f8 Mon Sep 17 00:00:00 2001 From: Brooke Bryan Date: Wed, 5 Aug 2015 16:18:06 +0100 Subject: [PATCH] less than [equal] / greater than [equal] validation --- src/Validation/PayloadValidator.php | 30 ++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Validation/PayloadValidator.php b/src/Validation/PayloadValidator.php index 2838163..cb6864f 100644 --- a/src/Validation/PayloadValidator.php +++ b/src/Validation/PayloadValidator.php @@ -150,7 +150,7 @@ public function runValidator($tag, $property, $value, $options) list($low, $high) = explode(' ', $options, 2); if(!Numbers::between(strlen($value), (int)$low, (int)$high)) { - $msg = "is not between " . (int)$low . ' and ' . (int)$high; + $msg = "is not between " . (int)$low . ' and ' . (int)$high . ' characters'; } break; case 'between': @@ -198,6 +198,34 @@ public function runValidator($tag, $property, $value, $options) $msg = 'is not a valid percentage'; } break; + case 'lessthan': + case 'lt': + if((int)$value >= (int)$options) + { + $msg = 'is not less than ' . (int)$options; + } + break; + case 'lessthanequal': + case 'lte': + if((int)$value > (int)$options) + { + $msg = 'is not less than or equal to ' . (int)$options; + } + break; + case 'greaterthan': + case 'gt': + if((int)$value <= (int)$options) + { + $msg = 'is not greater than ' . (int)$options; + } + break; + case 'greaterthanequal': + case 'gte': + if((int)$value < (int)$options) + { + $msg = 'is not greater than or equal to ' . (int)$options; + } + break; } if($msg !== null)