Patch: a validator that matches against another list if some other field has a specific value
This validator will match a field against a list of validators, but only if some other field matches some specific value. Possible usage scenario: a web interface for domain records where A records will require an IP in dotted notation while an CNAME record will require a fully qualified host name.
class MatchesIfOtherFieldEquals:
def __init__(self, other_field, other_value, validator_list=[]):
self.other_field = other_field
self.other_value = other_value
self.validator_list = validator_list
self.always_test = True
def __call__(self, field_data, all_data):
if all_data.has_key(self.other_field) and all_data[self.other_field] == self.other_value:
for v in self.validator_list:
v(field_data, all_data)
Change History
(2)
Summary: |
a validator that matches against another list if some other field has a specific value → Patch: a validator that matches against another list if some other field has a specific value
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
(In [405]) Fixed #266 -- Added ValidateIfOtherFieldEquals validator. Thanks again, Hugo