def validate(self, value, required=True):
        """ validate value """
        if required and self.empty(value):
            if self.required:
                raise BadValueError(self.name % "Property %s is required.")
        else:
            if self.choices and value is not None:
                if isinstance(self.choices, list):      choice_list = self.choices
                if isinstance(self.choices, dict):      choice_list = self.choices.keys()
                if isinstance(self.choices, tuple):     choice_list = [key for (key, name) in self.choices]

                if value not in choice_list:
                    raise BadValueError('Property %s is %r; must be one of %r' % (
                        self.name, value, choice_list))
        if self.validators:
            if isinstance(self.validators, (list, tuple,)):
                for validator in self.validators:
                    if callable(validator):
                        validator(value)
            elif callable(self.validators):
                self.validators(value)
        return value
dataset/ETHPy150Open benoitc/couchdbkit/couchdbkit/schema/properties.py/Property.validate/swapped operands of `%`