Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezintegervalidator.php
Go to the documentation of this file.
1 <?php
17 class eZIntegerValidator extends eZRegExpValidator
18 {
25 public function __construct( $min = false, $max = false )
26 {
27 $rule = array( "accepted" => "/^-?[0-9]+$/",
28 "intermediate" => "/(-?[0-9]+)/",
29 "fixup" => "" );
30 parent::__construct( $rule );
31 $this->MinValue = $min;
32 $this->MaxValue = $max;
33 if ( $max !== false and $min !== false )
34 $this->MaxValue = max( $min, $max );
35 }
36
37 function setRange( $min, $max )
38 {
39 $this->MinValue = $min;
40 $this->MaxValue = $max;
41 if ( $max !== false and $min !== false )
42 $this->MaxValue = max( $min, $max );
43 }
44
45 function validate( $text )
46 {
47 $state = eZRegExpValidator::validate( $text );
48 if ( $state == eZInputValidator::STATE_ACCEPTED )
49 {
50 if ( ( $this->MinValue !== false and $text < $this->MinValue ) or
51 ( $this->MaxValue !== false and $text > $this->MaxValue ) )
52 $state = eZInputValidator::STATE_INTERMEDIATE;
53 }
54 return $state;
55 }
56
57 function fixup( $text )
58 {
59 if ( preg_match( $this->RegExpRule["intermediate"], $text, $regs ) )
60 $text = $regs[1];
61 if ( $this->MinValue !== false and $text < $this->MinValue )
62 $text = $this->MinValue;
63 else if ( $this->MaxValue !== false and $text > $this->MaxValue )
64 $text = $this->MaxValue;
65 return $text;
66 }
67
69 public $MinValue;
70 public $MaxValue;
71 }
72
73 ?>
eZInputValidator\STATE_INTERMEDIATE
const STATE_INTERMEDIATE
Definition: ezinputvalidator.php:80
eZInputValidator\STATE_ACCEPTED
const STATE_ACCEPTED
Definition: ezinputvalidator.php:79
eZIntegerValidator
The class eZIntegerValidator does.
Definition: ezintegervalidator.php:18
eZIntegerValidator\fixup
fixup( $text)
Definition: ezintegervalidator.php:57
eZIntegerValidator\$MaxValue
$MaxValue
Definition: ezintegervalidator.php:70
eZIntegerValidator\setRange
setRange( $min, $max)
Definition: ezintegervalidator.php:37
eZIntegerValidator\validate
validate( $text)
Definition: ezintegervalidator.php:45
eZIntegerValidator\$MinValue
$MinValue
Definition: ezintegervalidator.php:69
eZIntegerValidator\__construct
__construct( $min=false, $max=false)
Definition: ezintegervalidator.php:25
eZRegExpValidator
Input validation using regexps.
Definition: ezregexpvalidator.php:18
eZRegExpValidator\validate
validate( $text)
Definition: ezregexpvalidator.php:34
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.