21
21
class Validator (object ):
22
22
"""Object used to configure validation of all objects in rfc3986.
23
23
24
+ .. versionadded:: 1.0
25
+
24
26
Example usage::
25
27
26
28
>>> from rfc3986 import api, validators
@@ -72,6 +74,8 @@ def __init__(self):
72
74
def allow_schemes (self , * schemes ):
73
75
"""Require the scheme to be one of the provided schemes.
74
76
77
+ .. versionadded:: 1.0
78
+
75
79
:param schemes:
76
80
Schemes, without ``://`` that are allowed.
77
81
:returns:
@@ -86,6 +90,8 @@ def allow_schemes(self, *schemes):
86
90
def allow_hosts (self , * hosts ):
87
91
"""Require the host to be one of the provided hosts.
88
92
93
+ .. versionadded:: 1.0
94
+
89
95
:param hosts:
90
96
Hosts that are allowed.
91
97
:returns:
@@ -100,6 +106,8 @@ def allow_hosts(self, *hosts):
100
106
def allow_ports (self , * ports ):
101
107
"""Require the port to be one of the provided ports.
102
108
109
+ .. versionadded:: 1.0
110
+
103
111
:param ports:
104
112
Ports that are allowed.
105
113
:returns:
@@ -114,18 +122,36 @@ def allow_ports(self, *ports):
114
122
return self
115
123
116
124
def allow_use_of_password (self ):
117
- """Allow passwords to be present in the URI."""
125
+ """Allow passwords to be present in the URI.
126
+
127
+ .. versionadded:: 1.0
128
+
129
+ :returns:
130
+ The validator instance.
131
+ :rtype:
132
+ Validator
133
+ """
118
134
self .allow_password = True
119
135
return self
120
136
121
137
def forbid_use_of_password (self ):
122
- """Prevent passwords from being included in the URI."""
138
+ """Prevent passwords from being included in the URI.
139
+
140
+ .. versionadded:: 1.0
141
+
142
+ :returns:
143
+ The validator instance.
144
+ :rtype:
145
+ Validator
146
+ """
123
147
self .allow_password = False
124
148
return self
125
149
126
150
def require_presence_of (self , * components ):
127
151
"""Require the components provided.
128
152
153
+ .. versionadded:: 1.0
154
+
129
155
:param components:
130
156
Names of components from :attr:`Validator.COMPONENT_NAMES`.
131
157
:returns:
@@ -147,6 +173,8 @@ def require_presence_of(self, *components):
147
173
def validate (self , uri ):
148
174
"""Check a URI for conditions specified on this validator.
149
175
176
+ .. versionadded:: 1.0
177
+
150
178
:param uri:
151
179
Parsed URI to validate.
152
180
:type uri:
0 commit comments