'Validates a subnet.'

def Validate(self, value, unused_key=None):

    if (value is None):
        raise validation.MissingAttribute('subnet    must    be    specified')
    if (not isinstance(value, basestring)):
        raise validation.ValidationError(("subnet    must    be    a    string,    not    '%r'" % type(value)))
    try:
        ipaddr.IPNetwork(value)
    except ValueError:
        raise validation.ValidationError(('%s    is    not    a    valid    IPv4    or    IPv6    subnet' % value))
    parts = value.split('/')
    if ((len(parts) == 2) and (not re.match('^[0-9]+$', parts[1]))):
        raise validation.ValidationError(('Prefix    length    of    subnet    %s    must    be    an    integer    (quad-dotted    masks    are    not    supported)' % value))
    return value
