Schema change for IP range, use validator instead of type
Custom types became rather useless in Cerberus 1.0 since the type checker is cripled (doesn't know field name, cannot return useful/detailed error messages). Instead we use a validator now.
This commit is contained in:
@@ -143,7 +143,7 @@ class ValidateCustomFields(Validator):
|
||||
if not value:
|
||||
self._error(field, "Value is required once the document was created")
|
||||
|
||||
def _validate_type_iprange(self, field_name: str, value: str):
|
||||
def _validator_iprange(self, field_name: str, value: str):
|
||||
"""Ensure the field contains a valid IP address.
|
||||
|
||||
Supports both IPv6 and IPv4 ranges. Requires the IPy module.
|
||||
|
@@ -227,7 +227,7 @@ organizations_schema = {
|
||||
'start': {'type': 'binary', 'required': True},
|
||||
'end': {'type': 'binary', 'required': True},
|
||||
'prefix': {'type': 'integer', 'required': True},
|
||||
'human': {'type': 'iprange', 'required': True},
|
||||
'human': {'type': 'string', 'required': True, 'validator': 'iprange'},
|
||||
}
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user