1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect2 id="zend.validate.set.between">
<title>Between</title>
<para>
<classname>Zend_Validate_Between</classname> allows you to validate if a given value is
between two other values.
</para>
<note>
<title>Zend_Validate_Between supports only number validation</title>
<para>
It should be noted that <classname>Zend_Validate_Between</classname> supports only the
validation of numbers. Strings or dates can not be validated with this validator.
</para>
</note>
<sect3 id="zend.validate.set.between.options">
<title>Supported options for Zend_Validate_Between</title>
<para>
The following options are supported for <classname>Zend_Validate_Between</classname>:
</para>
<itemizedlist>
<listitem>
<para>
<emphasis><property>inclusive</property></emphasis>: Defines if the validation
is inclusive the minimum and maximum border values or exclusive. It defaults
to <constant>TRUE</constant>.
</para>
</listitem>
<listitem>
<para>
<emphasis><property>max</property></emphasis>: Sets the maximum border for the
validation.
</para>
</listitem>
<listitem>
<para>
<emphasis><property>min</property></emphasis>: Sets the minimum border for the
validation.
</para>
</listitem>
</itemizedlist>
</sect3>
<sect3 id="zend.validate.set.between.basic">
<title>Default behaviour for Zend_Validate_Between</title>
<para>
Per default this validator checks if a value is between <property>min</property> and
<property>max</property> where both border values are allowed as value.
</para>
<programlisting language="php"><![CDATA[
$valid = new Zend_Validate_Between(array('min' => 0, 'max' => 10));
$value = 10;
$result = $valid->isValid($value);
// returns true
]]></programlisting>
<para>
In the above example the result is <constant>TRUE</constant> due to the reason that per
default the search is inclusively the border values. This means in our case that any
value from '0' to '10' is allowed. And values like '-1' and '11' will return
<constant>FALSE</constant>.
</para>
</sect3>
<sect3 id="zend.validate.set.between.inclusively">
<title>Validation exclusive the border values</title>
<para>
Sometimes it is useful to validate a value by excluding the border values. See the
following example:
</para>
<programlisting language="php"><![CDATA[
$valid = new Zend_Validate_Between(
array(
'min' => 0,
'max' => 10,
'inclusive' => false
)
);
$value = 10;
$result = $valid->isValid($value);
// returns false
]]></programlisting>
<para>
The example is almost equal to our first example but we excluded the border value. Now
the values '0' and '10' are no longer allowed and will return
<constant>FALSE</constant>.
</para>
</sect3>
</sect2>
<!--
vim:se ts=4 sw=4 et:
-->
|