Beispiel #1
0
 def __call__(self, value):
     if value in ['____-__-__', '    -  -  ',
                  '  /  /    ', '__/__/____',
                  '(  )     -    ', '(__) ____-____']:
         value = ''
     value, empty = is_empty(value, empty_regex=self.empty_regex)
     if empty:
         return (self.null, None)
     if isinstance(self.other, (list, tuple)):
         for item in self.other:
             value, error = item(value)
             if error:
                 break
         return value, error
     else:
         return self.other(value)
Beispiel #2
0
 def __call__(self, value):
     okay = (value, None)
     error = (value, self.error_message)
     # Return okay either the 'value', or one of self.others is not empty.
     values = []
     values.append(value)
     values.extend(self.others)
     empties = []
     for v in values:
         unused_v, empty = is_empty(v)
         empties.append(empty)
     # Example empties == [True, True, False]
     # If one False exists, it's valid
     if reduce(lambda x, y: x and y, empties):
         return error
     return okay