2010-10-18 06:26:02 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Respect\Validation\Exceptions;
|
|
|
|
|
2010-12-02 22:04:10 +01:00
|
|
|
class BetweenException extends ValidationException
|
2010-10-18 06:26:02 +02:00
|
|
|
{
|
2011-02-08 23:10:58 +01:00
|
|
|
const BOTH = 0;
|
|
|
|
const LOWER = 1;
|
|
|
|
const GREATER = 2;
|
2011-01-31 01:17:06 +01:00
|
|
|
|
2010-12-02 22:04:10 +01:00
|
|
|
public static $defaultTemplates = array(
|
2011-02-08 23:10:58 +01:00
|
|
|
self::BOTH => '%s must be between %s and %s',
|
|
|
|
self::LOWER => '%s must be greater than %2$s',
|
|
|
|
self::GREATER => '%s must be lower than %3$s',
|
2010-10-18 10:18:46 +02:00
|
|
|
);
|
|
|
|
|
2011-02-08 23:10:58 +01:00
|
|
|
public function configure($name, $min, $max)
|
|
|
|
{
|
|
|
|
return parent::configure(
|
|
|
|
$name, ValidationException::stringify($min), //TODO find a better way
|
|
|
|
ValidationException::stringify($max)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function chooseTemplate($name, $min, $max)
|
|
|
|
{
|
|
|
|
if (is_null($min))
|
|
|
|
return static::GREATER;
|
|
|
|
elseif (is_null($max))
|
|
|
|
return static::LOWER;
|
|
|
|
else
|
|
|
|
return static::BOTH;
|
|
|
|
}
|
|
|
|
|
2010-10-18 06:26:02 +02:00
|
|
|
}
|