Skip to content

Commit

Permalink
less than [equal] / greater than [equal] validation
Browse files Browse the repository at this point in the history
  • Loading branch information
bajb committed Aug 5, 2015
1 parent e5d5dad commit ca2ec1c
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/Validation/PayloadValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ca2ec1c

Please sign in to comment.