Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#266 closed enhancement (fixed)

Patch: a validator that matches against another list if some other field has a specific value

Reported by: hugo <gb@…> Owned by: adrian
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

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)

comment:1 Changed 10 years ago by hugo <gb@…>

  • Summary changed from a validator that matches against another list if some other field has a specific value to Patch: a validator that matches against another list if some other field has a specific value

comment:2 Changed 10 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(In [405]) Fixed #266 -- Added ValidateIfOtherFieldEquals validator. Thanks again, Hugo

Note: See TracTickets for help on using tickets.
Back to Top