Example #1
0
 def _validate_impl(self, value, name):
     v = ArgValidatorStr._validate_impl(self, value, name)
     try:
         addr, family = Util.parse_ip(v, self.family)
     except Exception:
         raise ValidationError(
             name,
             "value '%s' is not a valid IP%s address"
             % (value, Util.addr_family_to_v(self.family)),
         )
     if self.plain_address:
         return addr
     return {"family": family, "address": addr}
Example #2
0
 def _validate_impl(self, value, name):
     if isinstance(value, Util.STRING_TYPE):
         v = str(value)
         if not v:
             raise ValidationError(name, "cannot be empty")
         try:
             return Util.parse_address(v, self.family)
         except Exception:
             raise ValidationError(
                 name,
                 "value '%s' is not a valid IP%s address with prefix length"
                 % (value, Util.addr_family_to_v(self.family)),
             )
     v = ArgValidatorDict._validate_impl(self, value, name)
     return {
         "address": v["address"]["address"],
         "family": v["address"]["family"],
         "prefix": v["prefix"],
     }