Opened 19 years ago

Closed 19 years ago

Last modified 18 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 Holovaty
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: no UI/UX: no

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 by hugo <gb@…>, 19 years ago

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

comment:2 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

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

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