code: def to_data(self, value):
          '''
          Coerce python data type to simple form for serialization.
          If default value was defined returns the default value if None was passed.
          Throw exception is value is ``None`` is ``required`` is set to ``True``
          '''
          try:
              if value is None and self._default is not None:
                  return self._export(self.default)
              self._check_required(value)
              value = self._export(value)
              return value
          except ValueError as ex:
              raise ValueError(ex, self._errors['to_data']f to_data(self, value):
          '''
          Coerce python data type to simple form for serialization.
          If default value was defined returns the default value if None was passed.
          Throw exception is value is ``None`` is ``required`` is set to ``True``
          '''
          try:
              if value is None and self._default is not None:
                  return self._export(self.default)
              self._check_required(value)
              value = self._export(value)
              return value
          except ValueError as ex:
              raise ValueError(ex, self._errors['to_data'])
docs: Coerce python data type to simple form for serialization.
          If default value was defined returns the default value if None was passed.
          Throw exception is value is ``None`` is ``required`` is set to ``True``