Commits

Antoine Millet committed 362093a

Added Url type

  • Participants
  • Parent commits 8ccb40b

Comments (0)

Files changed (2)

File docs/schema/types.rst

 .. autoclass:: dotconf.schema.types.String
 .. autoclass:: dotconf.schema.types.IPAddress
 .. autoclass:: dotconf.schema.types.IPNetwork
+.. autoclass:: dotconf.schema.types.Url
 
 
 Number based types

File dotconf/schema/types.py

 """ Builtin types of dotconf.schema
 """
 
+import urlparse
+
 try:
     import ipaddr
 except ImportError:
                                   % (value, self._version))
         except ValueError as err:
             raise ValidationError(str(err))
+
+
+class Url(String):
+
+    """ A string based type representing an URL.
+
+    This type return an urlparse.ParseResult object.
+
+    Example in configuration::
+
+        proxy = "http://proxy:3128"
+    """
+
+    def validate(self, value):
+        try:
+            return urlparse.urlparse(value)
+        except ValueError as err:
+            raise ValidationError(str(err))