Zend_Validate-Isbn.xml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect2 id="zend.validate.set.isbn">
  4. <title>Isbn</title>
  5. <para>
  6. <classname>Zend_Validate_Isbn</classname> allows you to validate an
  7. <acronym>ISBN-10</acronym> or <acronym>ISBN-13</acronym> value.
  8. </para>
  9. <sect3 id="zend.validate.set.isbn.basic">
  10. <title>Basic usage</title>
  11. <para>
  12. A basic example of usage is below:
  13. </para>
  14. <programlisting language="php"><![CDATA[
  15. $validator = new Zend_Validate_Isbn();
  16. if ($validator->isValid($isbn)) {
  17. // isbn is valid
  18. } else {
  19. // isbn is not valid
  20. }
  21. ]]></programlisting>
  22. <para>
  23. This will validate any <acronym>ISBN-10</acronym> and <acronym>ISBN-13</acronym> without
  24. separator.
  25. </para>
  26. </sect3>
  27. <sect3 id="zend.validate.set.isbn.type-explicit">
  28. <title>Setting an explicit ISBN validation type</title>
  29. <para>
  30. An example of an <acronym>ISBN</acronym> type restriction is below:
  31. </para>
  32. <programlisting language="php"><![CDATA[
  33. $validator = new Zend_Validate_Isbn();
  34. $validator->setType(Zend_Validate_Isbn::ISBN13);
  35. // OR
  36. $validator = new Zend_Validate_Isbn(array(
  37. 'type' => Zend_Validate_Isbn::ISBN13,
  38. ));
  39. if ($validator->isValid($isbn)) {
  40. // this is a valid ISBN-13 value
  41. } else {
  42. // this is an invalid ISBN-13 value
  43. }
  44. ]]></programlisting>
  45. <para>
  46. The above will validate only <acronym>ISBN-13</acronym> values.
  47. </para>
  48. <para>
  49. Valid types include:
  50. </para>
  51. <itemizedlist>
  52. <listitem>
  53. <para><constant>Zend_Validate_Isbn::AUTO</constant> (default)</para>
  54. </listitem>
  55. <listitem>
  56. <para><constant>Zend_Validate_Isbn::ISBN10</constant></para>
  57. </listitem>
  58. <listitem>
  59. <para><constant>Zend_Validate_Isbn::ISBN13</constant></para>
  60. </listitem>
  61. </itemizedlist>
  62. </sect3>
  63. <sect3 id="zend.validate.set.isbn.separator">
  64. <title>Specifying a separator restriction</title>
  65. <para>
  66. An example of separator restriction is below:
  67. </para>
  68. <programlisting language="php"><![CDATA[
  69. $validator = new Zend_Validate_Isbn();
  70. $validator->setSeparator('-');
  71. // OR
  72. $validator = new Zend_Validate_Isbn(array(
  73. 'separator' => '-',
  74. ));
  75. if ($validator->isValid($isbn)) {
  76. // this is a valid ISBN with separator
  77. } else {
  78. // this is an invalid ISBN with separator
  79. }
  80. ]]></programlisting>
  81. <note>
  82. <title>Values without separator</title>
  83. <para>
  84. This will return <constant>FALSE</constant> if <varname>$isbn</varname> doesn't
  85. contain a separator <emphasis>or</emphasis> if it's an invalid
  86. <acronym>ISBN</acronym> value.
  87. </para>
  88. </note>
  89. <para>
  90. Valid separators include:
  91. </para>
  92. <itemizedlist>
  93. <listitem><para>"" (empty) (default)</para></listitem>
  94. <listitem><para>"-" (hyphen)</para></listitem>
  95. <listitem><para>" " (space)</para></listitem>
  96. </itemizedlist>
  97. </sect3>
  98. </sect2>
  99. <!--
  100. vim:se ts=4 sw=4 et:
  101. -->