File: Zend_Validate-Isbn.xml

package info (click to toggle)
zendframework 1.12.9%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 133,584 kB
  • sloc: xml: 1,311,829; php: 570,173; sh: 170; makefile: 125; sql: 121
file content (150 lines) | stat: -rw-r--r-- 4,357 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect2 id="zend.validate.set.isbn">
    <title>Isbn</title>

    <para>
        <classname>Zend_Validate_Isbn</classname> allows you to validate an
        <acronym>ISBN-10</acronym> or <acronym>ISBN-13</acronym> value.
    </para>

    <sect3 id="zend.validate.set.isbn.options">
        <title>Supported options for Zend_Validate_Isbn</title>

        <para>
            The following options are supported for <classname>Zend_Validate_Isbn</classname>:
        </para>

        <itemizedlist>
            <listitem>
                <para>
                    <emphasis><property>separator</property></emphasis>: Defines the allowed
                    separator for the <acronym>ISBN</acronym> number. It defaults to an empty
                    string.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis><property>type</property></emphasis>: Defines the allowed type of
                    <acronym>ISBN</acronym> numbers. It defaults to
                    <constant>Zend_Validate_Isbn::AUTO</constant>. For details take a look at
                    <link linkend="zend.validate.set.isbn.type-explicit">this section</link>.
                </para>
            </listitem>
        </itemizedlist>
    </sect3>

    <sect3 id="zend.validate.set.isbn.basic">
        <title>Basic usage</title>

        <para>
            A basic example of usage is below:
        </para>

        <programlisting language="php"><![CDATA[
$validator = new Zend_Validate_Isbn();
if ($validator->isValid($isbn)) {
    // isbn is valid
} else {
    // isbn is not valid
}
]]></programlisting>

        <para>
            This will validate any <acronym>ISBN-10</acronym> and <acronym>ISBN-13</acronym> without
            separator.
        </para>
    </sect3>

    <sect3 id="zend.validate.set.isbn.type-explicit">
        <title>Setting an explicit ISBN validation type</title>

        <para>
            An example of an <acronym>ISBN</acronym> type restriction is below:
        </para>

        <programlisting language="php"><![CDATA[
$validator = new Zend_Validate_Isbn();
$validator->setType(Zend_Validate_Isbn::ISBN13);
// OR
$validator = new Zend_Validate_Isbn(array(
    'type' => Zend_Validate_Isbn::ISBN13,
));

if ($validator->isValid($isbn)) {
    // this is a valid ISBN-13 value
} else {
    // this is an invalid ISBN-13 value
}
]]></programlisting>

        <para>
            The above will validate only <acronym>ISBN-13</acronym> values.
        </para>

        <para>
            Valid types include:
        </para>

        <itemizedlist>
            <listitem>
                <para><constant>Zend_Validate_Isbn::AUTO</constant> (default)</para>
            </listitem>

            <listitem>
                <para><constant>Zend_Validate_Isbn::ISBN10</constant></para>
            </listitem>

            <listitem>
                <para><constant>Zend_Validate_Isbn::ISBN13</constant></para>
            </listitem>
        </itemizedlist>
    </sect3>

    <sect3 id="zend.validate.set.isbn.separator">
        <title>Specifying a separator restriction</title>

        <para>
            An example of separator restriction is below:
        </para>

        <programlisting language="php"><![CDATA[
$validator = new Zend_Validate_Isbn();
$validator->setSeparator('-');
// OR
$validator = new Zend_Validate_Isbn(array(
    'separator' => '-',
));

if ($validator->isValid($isbn)) {
    // this is a valid ISBN with separator
} else {
    // this is an invalid ISBN with separator
}
]]></programlisting>

        <note>
            <title>Values without separator</title>

            <para>
                This will return <constant>FALSE</constant> if <varname>$isbn</varname> doesn't
                contain a separator <emphasis>or</emphasis> if it's an invalid
                <acronym>ISBN</acronym> value.
            </para>
        </note>

        <para>
            Valid separators include:
        </para>

        <itemizedlist>
            <listitem><para>"" (empty) (default)</para></listitem>
            <listitem><para>"-" (hyphen)</para></listitem>
            <listitem><para>" " (space)</para></listitem>
        </itemizedlist>
    </sect3>
</sect2>
<!--
vim:se ts=4 sw=4 et:
-->