code: def validate(self, value, model_instance):
          
          if not isinstance(value, base.StateWrapper):
              raise exceptions.ValidationError(self.error_messages['wrong_type'] % value)
          elif not value.workflow == self.workflow:
              raise exceptions.ValidationError(self.error_messages['wrong_workflow'] % value.workflow)
          elif value.state not in self.workflow.states:
              raise exceptions.ValidationError(self.error_messages['invalid_state'] % value.state)
docs: Validate that a given value is a valid option for a given model instance.
  
          Args:
              value (xworkflows.base.StateWrapper): The base.StateWrapper returned by to_python.
              model_instance: A WorkflowEnabled instance