confu.schema.inet
Attributes that deal with networking specific values such as emails, urls and ip addresses
These can be imported directly from confu.schema
Requirements
ipaddress
for ip address validation
Classes
Email(confu.schema.core.Str)
Describes an email address
Methods
validate
def validate(self, value, path, **kwargs)
Validate a value for this attribute
Will raise a ValidationError
or ValidationWarning
exception on
validation failure
Arguments
- value (
mixed
): the value to validate - path (
list
): current path in the config schema, this is mostly used to identify where an error occured when validating against config data, you can pass an empty list to it when calling this manually
IpAddress
IpAddress(confu.schema.core.Str)
Describes a IPv4 or IPv6 address
Methods
__init__
def __init__(self, name=, protocol=None, **kwargs)
Initialize attribute
Keyword Arguments
- name (
str
): describes the attribute name, if not specified explicitly will be set through the schema that instantiates the attribute. - protocol (
int
): ip version, can be 4, 6 or None - if it is none the attribute can hold either a v4 or a v6 IP address. - default (
mixed
): the default value of this attribute. Once a default value is set, schema validation will no longer raise a validation error if the attribute is missing from the configuration. - choices (
list
): if specified on values in this list may be set for this attribute - help (
str
): help description - cli (
bool=True
): enable CLI support for this attribute - deprecated (
str
): version id of when this attribute will be deprecated - added (
str
): version id of when this attribute was added to the schema - removed (
str
): version id of when this attribute will be removed
validate
def validate(self, value, path, **kwargs)
Validate a value for this attribute
Will raise a ValidationError
or ValidationWarning
exception on
validation failure
Arguments
- value (
mixed
): the value to validate - path (
list
): current path in the config schema, this is mostly used to identify where an error occured when validating against config data, you can pass an empty list to it when calling this manually
Url
Url(confu.schema.core.Str)
Describes a URL
Methods
__init__
def __init__(self, name=, **kwargs)
Initialize attribute
Keyword Arguments
- name (
str
): describes the attribute name, if not specified explicitly will be set through the schema that instantiates the attribute. - default (
mixed
): the default value of this attribute. Once a default value is set, schema validation will no longer raise a validation error if the attribute is missing from the configuration. - choices (
list
): if specified on values in this list may be set for this attribute - help (
str
): help description - cli (
bool=True|function
): enable CLI support for this attribute - deprecated (
str
): version id of when this attribute will be deprecated - added (
str
): version id of when this attribute was added to the schema - removed (
str
): version id of when this attribute will be removed
validate
def validate(self, value, path, **kwargs)
Currently only validates by running urlparse against it and checking that a scheme and netloc is set - and if a list of allowed schemes is provide that the scheme is valid against that list
TODO: may want something more sophisticated than that - could look at django's url validator