1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.validate.set" xmlns:xi="http://www.w3.org/2001/XInclude">
4 <title>Standard Validation Classes</title>
7 Zend Framework comes with a standard set of validation classes, which are ready for you to
11 <sect2 id="zend.validate.set.alnum">
15 Returns <constant>TRUE</constant> if and only if <varname>$value</varname> contains only
16 alphabetic and digit characters. This validator includes an option to also consider
17 white space characters as valid.
22 The alphabetic characters mean characters that makes up words in each language.
23 However, the English alphabet is treated as the alphabetic characters in following
24 languages: Chinese, Japanese, Korean. The language is specified by
25 <classname>Zend_Locale</classname>.
30 <sect2 id="zend.validate.set.alpha">
34 Returns <constant>TRUE</constant> if and only if <varname>$value</varname> contains only
35 alphabetic characters. This validator includes an option to also consider white space
40 <xi:include href="Zend_Validate-Barcode.xml" />
41 <xi:include href="Zend_Validate-Between.xml" />
42 <xi:include href="Zend_Validate-Callback.xml" />
43 <xi:include href="Zend_Validate-CreditCard.xml" />
45 <sect2 id="zend.validate.set.ccnum">
50 The <classname>Ccnum</classname> validator has been deprecated in favor of the
51 <classname>CreditCard</classname> validator. For security reasons you should use
52 CreditCard instead of Ccnum.
57 <sect2 id="zend.validate.set.date">
61 Returns <constant>TRUE</constant> if <varname>$value</varname> is a valid date of the
62 format 'YYYY-MM-DD'. If the optional <property>locale</property> option is set then the
63 date will be validated according to the set locale. And if the optional
64 <property>format</property> option is set this format is used for the validation. for
65 details about the optional parameters see <link
66 linkend="zend.date.others.comparison.table">Zend_Date::isDate()</link>.
70 <xi:include href="Zend_Validate-Db.xml" />
72 <sect2 id="zend.validate.set.digits">
76 Returns <constant>TRUE</constant> if and only if <varname>$value</varname> only contains
81 <xi:include href="Zend_Validate-EmailAddress.xml" />
83 <sect2 id="zend.validate.set.float">
87 Returns <constant>TRUE</constant> if and only if <varname>$value</varname> is a
88 floating-point value. Since Zend Framework 1.8 this validator takes into account the
89 actual locale from browser, environment or application wide set locale. You can of
90 course use the get/setLocale accessors to change the used locale or give it while
91 creating a instance of this validator.
95 <sect2 id="zend.validate.set.greater_than">
96 <title>GreaterThan</title>
99 Returns <constant>TRUE</constant> if and only if <varname>$value</varname> is greater
100 than the minimum boundary.
104 <xi:include href="Zend_Validate-Hex.xml" />
105 <xi:include href="Zend_Validate-Hostname.xml" />
107 <sect2 id="zend.validate.set.iban">
111 Returns <constant>TRUE</constant> if and only if <varname>$value</varname> contains a
112 valid IBAN (International Bank Account Number). IBAN numbers are validated against the
113 country where they are used and by a checksum.
117 There are two ways to validate IBAN numbers. As first way you can give a locale which
118 represents a country. Any given IBAN number will then be validated against this country.
121 <programlisting language="php"><![CDATA[
122 $validator = new Zend_Validate_Iban('de_AT');
123 $iban = 'AT611904300234573201';
124 if ($validator->isValid($iban)) {
125 // IBAN appears to be valid
128 foreach ($validator->getMessages() as $message) {
135 This should be done when you want to validate IBAN numbers for a single countries. The
136 simpler way of validation is not to give a locale like shown in the next example.
139 <programlisting language="php"><![CDATA[
140 $validator = new Zend_Validate_Iban();
141 $iban = 'AT611904300234573201';
142 if ($validator->isValid($iban)) {
143 // IBAN appears to be valid
150 But this shows one big problem: When you have to accept only IBAN numbers from one
151 single country, for example france, then IBAN numbers from other countries would also be
152 valid. Therefor just remember: When you have to validate a IBAN number against a defined
153 country you should give the locale. And when you accept all IBAN numbers regardless of
154 any country omit the locale for simplicity.
158 <xi:include href="Zend_Validate-Identical.xml" />
159 <xi:include href="Zend_Validate-InArray.xml" />
161 <sect2 id="zend.validate.set.int">
165 Returns <constant>TRUE</constant> if and only if <varname>$value</varname> is a valid
166 integer. Since Zend Framework 1.8 this validator takes into account the actual locale
167 from browser, environment or application wide set locale. You can of course use the
168 get/setLocale accessors to change the used locale or give it while creating a instance
173 <xi:include href="Zend_Validate-Ip.xml" />
174 <xi:include href="Zend_Validate-Isbn.xml" />
176 <sect2 id="zend.validate.set.less_than">
177 <title>LessThan</title>
180 Returns <constant>TRUE</constant> if and only if <varname>$value</varname> is less than
181 the maximum boundary.
185 <xi:include href="Zend_Validate-NotEmpty.xml" />
186 <xi:include href="Zend_Validate-PostCode.xml" />
188 <sect2 id="zend.validate.set.regex">
192 Returns <constant>TRUE</constant> if and only if <varname>$value</varname> matches
193 against a regular expression pattern.
197 <xi:include href="Zend_Validate-Sitemap.xml" />
199 <sect2 id="zend.validate.set.string_length">
200 <title>StringLength</title>
203 Returns <constant>TRUE</constant> if and only if the string length of
204 <varname>$value</varname> is at least a minimum and no greater than a maximum (when the
205 max option is not <constant>NULL</constant>). The <methodname>setMin()</methodname>
206 method throws an exception if the minimum length is set to a value greater than the set
207 maximum length, and the <methodname>setMax()</methodname> method throws an exception if
208 the maximum length is set to a value less than the set minimum length. This class
209 supports UTF-8 and other character encodings, based on the current value of <ulink
210 url="http://www.php.net/manual/en/ref.iconv.php#iconv.configuration">iconv.internal_encoding</ulink>.
211 If you need a different encoding you can set it with the accessor methods getEncoding