Logo Search packages:      
Sourcecode: zope-formulator version File versions  Download package

def Formulator::PatternChecker::PatternChecker::validate_value (   self,
  patterns,
  value 
)

Validate method that manges the entire validation process.

The validator goes through each pattern and
tries to get a match to the value (second parameter). At the end, the
first pattern of the list is taken to construct the value again; this
ensures data cleansing and a common data look.

Definition at line 95 of file PatternChecker.py.

00095                                              :
        """Validate method that manges the entire validation process.

        The validator goes through each pattern and
        tries to get a match to the value (second parameter). At the end, the
        first pattern of the list is taken to construct the value again; this
        ensures data cleansing and a common data look.
        """
        value = self.clean_value(value)

        result = None
        for pattern in patterns:
            regex = self.make_regex_from_pattern(pattern)
            re_obj = re.compile(regex)
            result = re_obj.search(value)
            if result:
                break

        if not result:
            return None

        value = self.construct_value_from_match(result, patterns[0])
        return self._unescape_special_characters(value)
        return self._unescape_special_characters(value)


Generated by  Doxygen 1.6.0   Back to index