|
|
@@ -0,0 +1,104 @@
|
|
|
+<?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 Zend_Validate_Between 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>min</property></emphasis>: Sets the minimum border for the
|
|
|
+ validation.
|
|
|
+ </para>
|
|
|
+ </listitem>
|
|
|
+
|
|
|
+ <listitem>
|
|
|
+ <para>
|
|
|
+ <emphasis><property>max</property></emphasis>: Sets the maximum 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:
|
|
|
+-->
|