My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones  
Changes to /doc-src/manual/rfc3696.rst
4e7ed779a9fe vs. 8f2692346ba5 Compare: vs.  Format:
Revision 8f2692346ba5
Go to: 
Project members, sign in to write a code review
/doc-src/manual/rfc3696.rst   4e7ed779a9fe /doc-src/manual/rfc3696.rst   8f2692346ba5
1 1
2 .. index:: RFC 3696 2 .. index:: RFC 3696
3 .. _rfc3696: 3 .. _rfc3696:
4 4
5 RFC 3696 - Email and URL Validation 5 RFC 3696 - Email and URL Validation
6 =================================== 6 ===================================
7 7
8 `RFC 3696 <http://www.faqs.org/rfcs/rfc3696.html>`_ contains advice on how 8 `RFC 3696 <http://www.faqs.org/rfcs/rfc3696.html>`_ contains advice on how
9 best to validate email addresses, HTTP URLs, and "mailto" URLs. I strongly 9 best to validate email addresses, HTTP URLs, and "mailto" URLs. I strongly
10 recommend that you read that document before using this library --- it will 10 recommend that you read that document before using this library --- it will
11 help you better understand the motivation for these functions. In particular, 11 help you better understand the motivation for these functions. In particular,
12 they do not test whether arguments are *exactly compliant* with the 12 they do not test whether arguments are *exactly compliant* with the
13 appropriate specificatons; nor do they guarantee any particular properties. 13 appropriate specificatons; nor do they guarantee any particular properties.
14 14
15 My interpretation of that document is that these are reasonable heuristics 15 My interpretation of that document is that these are reasonable heuristics
16 that should help validate user input without causing too many false negatives. 16 that should help validate user input without causing too many false negatives.
17 That is all. 17 That is all.
18 18
19 As such, the public interface exposes only three simple functions. These are 19 As such, the public interface exposes only three simple functions. These are
20 factories that return a ``validator`` for each of the three types. 20 factories that return a ``validator`` for each of the three types.
21 21
22 .. _validator: 22 .. _validator:
23 .. function:: validator(value : string) -> bool 23 .. function:: validator(value : string) -> bool
24 :noindex: 24 :noindex:
25 25
26 A function which, given a string, returns either ``True`` (in which case 26 A function which, given a string, returns either ``True`` (in which case
27 the value is consistent wth RFC 3696) or ``False`` (inconsistent). 27 the value is consistent wth RFC 3696) or ``False`` (inconsistent).
28 28
29 The package *implementation* also contains various matchers for IP addresses, 29 The package *implementation* also contains various matchers for IP addresses,
30 etc. The names of these functions are prefixed by an underscore, and there is 30 etc. The names of these functions are prefixed by an underscore, and there is
31 no gaurantee that they will remain stable between any revision of this 31 no gaurantee that they will remain stable between any revision of this
32 library. Despite that, they may be useful as a reference, or to understand 32 library. Despite that, they may be useful as a reference, or to understand
33 better how Lepl can be used for validation. 33 better how Lepl can be used for validation.
34 34
35 .. module:: lepl.apps.rfc3696 35 .. module:: lepl.apps.rfc3696
36 :synopsis: Validate email, HTTP and mailto URLs. 36 :synopsis: Validate email, HTTP and mailto URLs.
37 .. moduleauthor:: Andrew Cooke <andrew@acooke.org> 37 .. moduleauthor:: Andrew Cooke <andrew@acooke.org>
38 38
39 All (public) functions can be imported with:: 39 All (public) functions can be imported with::
40 40
41 from lepl.apps.rfc3696 import * 41 from lepl.apps.rfc3696 import *
42 42
43 They are *not* available directly in the ``lepl`` package. 43 They are *not* available directly in the ``lepl`` package.
44 44
45 .. function:: Email() -> validator 45 .. function:: Email() -> validator
46 46
47 `Email() <api/redirect.html#lepl.apps.rfc3696.Email>`_: Generate a 47 ``Email()``: Generate a
48 `validator` for email addresses. 48 `validator` for email addresses.
49 49
50 .. function:: HttpUrl() -> validator 50 .. function:: HttpUrl() -> validator
51 51
52 `HttpUrl() <api/redirect.html#lepl.apps.rfc3696.HttpUrl>`_: Generate a 52 ``HttpUrl()``: Generate a
53 `validator` for HTTP URLs. 53 `validator` for HTTP URLs.
54 54
55 .. function:: MailToUrl() -> validator 55 .. function:: MailToUrl() -> validator
56 56
57 `MailToUrl() <api/redirect.html#lepl.apps.rfc3696.MailToUrl>`_: Generate a 57 ``MailToUrl()``: Generate a
58 `validator` for "mailto" URLs. 58 `validator` for "mailto" URLs.
59 59
60 .. note:: 60 .. note::
61 61
62 A warning like:: 62 A warning like::
63 63
64 No handlers could be found for logger "lepl.parser.trampoline" 64 No handlers could be found for logger "lepl.parser.trampoline"
65 65
66 means that you do not have Python's logging configured. If you are not 66 means that you do not have Python's logging configured. If you are not
67 using the logging package elsewhere then you can do the following to 67 using the logging package elsewhere then you can do the following to
68 suppress the error:: 68 suppress the error::
69 69
70 from logging import basicConfig, ERROR 70 from logging import basicConfig, ERROR
71 basicConfig(level=ERROR) 71 basicConfig(level=ERROR)
Powered by Google Project Hosting