code: def choices_validator(choices):
      
      def validator(value):
          if value not in choices:
              # note: make it a list for consistent representation
              raise ValidationError(
                  "{} is not in {}".format(value, list(choices))
              )
  
      return validator
docs: Return validator function that will check if ``value in choices``.
  
      Args:
          max_value (list, set, tuple): allowed choices for new validator