Pārlūkot izejas kodu

[ZF-8970] Zend_Validate:

- added new section for Zend_Validate_Date

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22066 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 15 gadi atpakaļ
vecāks
revīzija
f1caf32370

+ 108 - 0
documentation/manual/en/module_specs/Zend_Validate-Date.xml

@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Reviewed: no -->
+<sect2 id="zend.validate.set.date">
+    <title>Date</title>
+
+    <para>
+        <classname>Zend_Validate_Date</classname> allows you to validate if a given value contains
+        a date. This validator validates also localized input.
+    </para>
+
+    <sect3 id="zend.validate.set.date.options">
+        <title>Supported options for Zend_Validate_Date</title>
+
+        <para>
+            The following options are supported for <classname>Zend_Validate_Date</classname>:
+        </para>
+
+        <itemizedlist>
+            <listitem>
+                <para>
+                    <emphasis><property>format</property></emphasis>: Sets the format which is used
+                    to write the date.
+                </para>
+            </listitem>
+
+            <listitem>
+                <para>
+                    <emphasis><property>locale</property></emphasis>: Sets the locale which will be
+                    used to validate date values.
+                </para>
+            </listitem>
+        </itemizedlist>
+    </sect3>
+
+    <sect3 id="zend.validate.set.date.basic">
+        <title>Default date validation</title>
+
+        <para>
+            The easiest way to validate a date is by using the default date format. It is used when
+            no locale and no format has been given.
+        </para>
+
+        <programlisting language="php"><![CDATA[
+$validator = new Zend_Validate_Date();
+
+$validator->isValid('2000-10-10');   // returns true
+$validator->isValid('10.10.2000'); // returns false
+]]></programlisting>
+
+        <para>
+            The default date format for <classname>Zend_Validate_Date</classname> is 'yyyy-MM-dd'.
+        </para>
+    </sect3>
+
+    <sect3 id="zend.validate.set.date.localized">
+        <title>Localized date validation</title>
+
+        <para>
+            <classname>Zend_Validate_Date</classname> validates also dates which are given in a
+            localized format. By using the <property>locale</property> option you can define the
+            locale which the date format should use for validation.
+        </para>
+
+        <programlisting language="php"><![CDATA[
+$validator = new Zend_Validate_Date(array('locale' => 'de'));
+
+$validator->isValid('10.Feb.2010'); // returns true
+$validator->isValid('10.May.2010'); // returns false
+]]></programlisting>
+
+        <para>
+            The <property>locale</property> option sets the default date format. In the above
+            example this is 'dd.MM.yyyy' which is defined as default date format for 'de'.
+        </para>
+    </sect3>
+
+    <sect3 id="zend.validate.set.date.formats">
+        <title>Self defined date validation</title>
+
+        <para>
+            <classname>Zend_Validate_Date</classname> supports also self defined date formats.
+            When you want to validate such a date you can use the <property>format</property>
+            option.
+        </para>
+
+        <programlisting language="php"><![CDATA[
+$validator = new Zend_Validate_Date(array('format' => 'yyyy'));
+
+$validator->isValid('2010'); // returns true
+$validator->isValid('May');  // returns false
+]]></programlisting>
+
+        <para>
+            Of course you can combine <property>format</property> and <property>locale</property>.
+            In this case you can also use localized month or daynames.
+        </para>
+
+        <programlisting language="php"><![CDATA[
+$validator = new Zend_Validate_Date(array('format' => 'yyyy MMMM', 'locale' => 'de));
+
+$validator->isValid('2010 Dezember'); // returns true
+$validator->isValid('2010 June');     // returns false
+]]></programlisting>
+    </sect3>
+</sect2>
+<!--
+vim:se ts=4 sw=4 et:
+-->

+ 1 - 13
documentation/manual/en/module_specs/Zend_Validate-Set.xml

@@ -27,19 +27,7 @@
         </note>
     </sect2>
 
-    <sect2 id="zend.validate.set.date">
-        <title>Date</title>
-
-        <para>
-            Returns <constant>TRUE</constant> if <varname>$value</varname> is a valid date of the
-            format 'YYYY-MM-DD'. If the optional <property>locale</property> option is set then the
-            date will be validated according to the set locale. And if the optional
-            <property>format</property> option is set this format is used for the validation. for
-            details about the optional parameters see <link
-                linkend="zend.date.others.comparison.table">Zend_Date::isDate()</link>.
-        </para>
-    </sect2>
-
+    <xi:include href="Zend_Validate-Date.xml" />
     <xi:include href="Zend_Validate-Db.xml" />
     <xi:include href="Zend_Validate-Digits.xml" />
     <xi:include href="Zend_Validate-EmailAddress.xml" />