parameter</primary>
</indexterm>
</term>
<listitem>
<para>
<varname>isn.weak</varname> enables the weak input mode, which allows
ISN input values to be accepted even when their check digit is wrong.
The default is <literal>false</literal>, which rejects invalid check
digits.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
Why would you want to use the weak mode? Well, it could be that
you have a huge collection of ISBN numbers, and that there are so many of
them that for weird reasons some have the wrong check digit (perhaps the
numbers were scanned from a printed list and the OCR got the numbers wrong,
perhaps the numbers were manually captured... who knows). Anyway, the point
is you might want to clean the mess up, but you still want to be able to
have all the numbers in your database and maybe use an external tool to
locate the invalid numbers in the database so you can verify the
information and validate it more easily; so for example you'd want to
select all the invalid numbers in the table.
</para>
<para>
When you insert invalid numbers in a table using the weak mode, the number
will be inserted with the corrected check digit, but it will be displayed
with an exclamation mark (<literal>!</literal>) at the end, for example
<literal>0-11-000322-5!</literal>. This invalid marker can be checked with
the <function>is_valid</function> function and cleared with the
<function>make_valid</function> function.
</para>
<para>
You can also force the insertion of marked-as-invalid numbers even when not
in the weak mode, by appending the <literal>!</literal> character at the
end of the number.
</para>
<para>
Another special feature is that during input, you can write
<literal>?</literal> in place of the check digit, and the correct check digit
will be inserted automatically.
</para>
</sect2>
<sect2 id="isn-examples">
<title>Examples</title>
<programlisting>
--Using the types directly:
SELECT isbn('978-0-393-04002-9');
SELECT isbn13('0901690546');
SELECT issn('1436-4522');
--Casting types:
-- note that you can only cast from ean13 to another type when the
-- number would be valid in the realm of the target type;
-- thus, the following will NOT work: select isbn(ean13('0220356483481'));
-- but these will:
SELECT upc(ean13('0220356483481'));
SELECT ean13(upc('220356483481'));