code: def validate(self, value):
          
  
          # check choices
          if self.choices:
              if isinstance(self.choices[0], (list, tuple)):
                  option_keys = [k for k, v in self.choices]
                  if value not in option_keys:
                      msg = ('Value {0} is not listed among valid choices {1}'.format(value, option_keys))
                      self.raise_error(msg)
              elif value not in self.choices:
                  msg = ('Value {0} is not listed among valid choices {1}'.format(value, self.choices))
                  self.raise_error(msg)
docs: Performs validation of the value.
          :param value: value to validate
          :raise ValidationError if the value is invalid