Overview

Namespaces

  • None
  • PHP
  • Wei
    • Validator

Classes

  • All
  • AllOf
  • Alnum
  • Alpha
  • BaseValidator
  • Between
  • Blank
  • Callback
  • CharLength
  • Chinese
  • Color
  • Contains
  • CreditCard
  • Date
  • DateTime
  • Decimal
  • Digit
  • Dir
  • DivisibleBy
  • DoubleByte
  • Email
  • EndsWith
  • EqualTo
  • Exists
  • FieldExists
  • File
  • GreaterThan
  • GreaterThanOrEqual
  • IdCardCn
  • IdCardHk
  • IdCardMo
  • IdCardTw
  • IdenticalTo
  • Image
  • In
  • Ip
  • Length
  • LessThan
  • LessThanOrEqual
  • Lowercase
  • Luhn
  • MaxLength
  • MinLength
  • MobileCn
  • NaturalNumber
  • NoneOf
  • Null
  • Number
  • OneOf
  • Password
  • Phone
  • PhoneCn
  • PlateNumberCn
  • PositiveInteger
  • PostcodeCn
  • Present
  • QQ
  • RecordExists
  • Regex
  • Required
  • SomeOf
  • StartsWith
  • Time
  • Tld
  • Type
  • Uppercase
  • Url
  • Uuid
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Wei Framework
 4:  *
 5:  * @copyright   Copyright (c) 2008-2013 Twin Huang
 6:  * @license     http://opensource.org/licenses/mit-license.php MIT License
 7:  */
 8: 
 9: namespace Wei\Validator;
10: 
11: /**
12:  * Check if the input is between the specified minimum and maximum value
13:  *
14:  * @author      Twin Huang <twinhuang@qq.com>
15:  */
16: class Between extends BaseValidator
17: {
18:     protected $betweenMessage = '%name% must between %min% and %max%';
19: 
20:     protected $negativeMessage = '%name% must not between %min% and %max%';
21: 
22:     protected $min;
23: 
24:     protected $max;
25: 
26:     /**
27:      * {@inheritdoc}
28:      */
29:     public function __invoke($input, $min = null, $max = null)
30:     {
31:         // Allows not numeric parameter like 2000-01-01, 10:03, etc
32:         if ($min && $max) {
33:             $this->storeOption('min', $min);
34:             $this->storeOption('max', $max);
35:         }
36: 
37:         return $this->isValid($input);
38:     }
39: 
40:     /**
41:      * {@inheritdoc}
42:      */
43:     protected function doValidate($input)
44:     {
45:         if ($this->min > $input || $this->max < $input) {
46:             $this->addError('between');
47:             return false;
48:         }
49:         return true;
50:     }
51: }
52: 
Wei Framework API documentation generated by ApiGen