1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect2 id="zend.validate.set.isbn">
7 <classname>Zend_Validate_Isbn</classname> allows you to validate an
8 <acronym>ISBN-10</acronym> or <acronym>ISBN-13</acronym> value.
11 <sect3 id="zend.validate.set.isbn.options">
12 <title>Supported options for Zend_Validate_Isbn</title>
15 The following options are supported for <classname>Zend_Validate_Isbn</classname>:
21 <emphasis><property>separator</property></emphasis>: Defines the allowed
22 separator for the <acronym>ISBN</acronym> number. It defaults to an empty
29 <emphasis><property>type</property></emphasis>: Defines the allowed type of
30 <acronym>ISBN</acronym> numbers. It defaults to
31 <constant>Zend_Validate_Isbn::AUTO</constant>. For details take a look at
32 <link linkend="zend.validate.set.isbn.type-explicit">this section</link>.
38 <sect3 id="zend.validate.set.isbn.basic">
39 <title>Basic usage</title>
42 A basic example of usage is below:
45 <programlisting language="php"><![CDATA[
46 $validator = new Zend_Validate_Isbn();
47 if ($validator->isValid($isbn)) {
55 This will validate any <acronym>ISBN-10</acronym> and <acronym>ISBN-13</acronym> without
60 <sect3 id="zend.validate.set.isbn.type-explicit">
61 <title>Setting an explicit ISBN validation type</title>
64 An example of an <acronym>ISBN</acronym> type restriction is below:
67 <programlisting language="php"><![CDATA[
68 $validator = new Zend_Validate_Isbn();
69 $validator->setType(Zend_Validate_Isbn::ISBN13);
71 $validator = new Zend_Validate_Isbn(array(
72 'type' => Zend_Validate_Isbn::ISBN13,
75 if ($validator->isValid($isbn)) {
76 // this is a valid ISBN-13 value
78 // this is an invalid ISBN-13 value
83 The above will validate only <acronym>ISBN-13</acronym> values.
92 <para><constant>Zend_Validate_Isbn::AUTO</constant> (default)</para>
96 <para><constant>Zend_Validate_Isbn::ISBN10</constant></para>
100 <para><constant>Zend_Validate_Isbn::ISBN13</constant></para>
105 <sect3 id="zend.validate.set.isbn.separator">
106 <title>Specifying a separator restriction</title>
109 An example of separator restriction is below:
112 <programlisting language="php"><![CDATA[
113 $validator = new Zend_Validate_Isbn();
114 $validator->setSeparator('-');
116 $validator = new Zend_Validate_Isbn(array(
120 if ($validator->isValid($isbn)) {
121 // this is a valid ISBN with separator
123 // this is an invalid ISBN with separator
128 <title>Values without separator</title>
131 This will return <constant>FALSE</constant> if <varname>$isbn</varname> doesn't
132 contain a separator <emphasis>or</emphasis> if it's an invalid
133 <acronym>ISBN</acronym> value.
138 Valid separators include:
142 <listitem><para>"" (empty) (default)</para></listitem>
143 <listitem><para>"-" (hyphen)</para></listitem>
144 <listitem><para>" " (space)</para></listitem>