import six

from designate.objects import base


class ValidationError(base.DesignateObject):
    FIELDS = {
        'path': {},
        'message': {},
        'validator': {},
        'validator_value': {},
        'raw': {},
    }

    @classmethod
    def from_js_error(cls, js_error):
        """Convert a JSON Schema ValidationError instance into a
        ValidationError instance.
        """

        e = cls()
        e.path = list(getattr(js_error, 'releative_path', js_error.path))
        e.message = six.text_type(js_error)
        e.validator = js_error.validator
        e.validator_value = js_error.validator_value

        e.raw = js_error._contents()

        return e


class ValidationErrorList(base.ListObjectMixin, base.DesignateObject):
    LIST_ITEM_TYPE = ValidationError

from designate.objects import base


class ValidationError(base.DesignateObject):
    FIELDS = {
        'path': {},
        'message': {},
        'validator': {},
        'validator_value': {},
        'raw': {},
    }

    @classmethod
    def from_js_error(cls, js_error):
        """Convert a JSON Schema ValidationError instance into a
        ValidationError instance.
        """

        e = cls()
        e.path = list(getattr(js_error, 'releative_path', js_error.path))
        e.message = js_error.message
        e.validator = js_error.validator
        e.validator_value = js_error.validator_value

        e.raw = js_error._contents()

        return e


class ValidationErrorList(base.ListObjectMixin, base.DesignateObject):
    LIST_ITEM_TYPE = ValidationError

Fix the displayed error message in V2 API
Fix the displayed error message in V2 API

Change-Id: I07c3f1ed79fa507dbe9b76eb8f5964475516754c

- import six
- 
  from designate.objects import base
  
  
  class ValidationError(base.DesignateObject):
      FIELDS = {
          'path': {},
          'message': {},
          'validator': {},
          'validator_value': {},
          'raw': {},
      }
  
      @classmethod
      def from_js_error(cls, js_error):
          """Convert a JSON Schema ValidationError instance into a
          ValidationError instance.
          """
  
          e = cls()
          e.path = list(getattr(js_error, 'releative_path', js_error.path))
-         e.message = six.text_type(js_error)
+         e.message = js_error.message
          e.validator = js_error.validator
          e.validator_value = js_error.validator_value
  
          e.raw = js_error._contents()
  
          return e
  
  
  class ValidationErrorList(base.ListObjectMixin, base.DesignateObject):
      LIST_ITEM_TYPE = ValidationError
  
Fix the displayed error message in V2 API
## Code Before:
import six

from designate.objects import base


class ValidationError(base.DesignateObject):
    FIELDS = {
        'path': {},
        'message': {},
        'validator': {},
        'validator_value': {},
        'raw': {},
    }

    @classmethod
    def from_js_error(cls, js_error):
        """Convert a JSON Schema ValidationError instance into a
        ValidationError instance.
        """

        e = cls()
        e.path = list(getattr(js_error, 'releative_path', js_error.path))
        e.message = six.text_type(js_error)
        e.validator = js_error.validator
        e.validator_value = js_error.validator_value

        e.raw = js_error._contents()

        return e


class ValidationErrorList(base.ListObjectMixin, base.DesignateObject):
    LIST_ITEM_TYPE = ValidationError

## Instruction:
Fix the displayed error message in V2 API
## Code After:
from designate.objects import base


class ValidationError(base.DesignateObject):
    FIELDS = {
        'path': {},
        'message': {},
        'validator': {},
        'validator_value': {},
        'raw': {},
    }

    @classmethod
    def from_js_error(cls, js_error):
        """Convert a JSON Schema ValidationError instance into a
        ValidationError instance.
        """

        e = cls()
        e.path = list(getattr(js_error, 'releative_path', js_error.path))
        e.message = js_error.message
        e.validator = js_error.validator
        e.validator_value = js_error.validator_value

        e.raw = js_error._contents()

        return e


class ValidationErrorList(base.ListObjectMixin, base.DesignateObject):
    LIST_ITEM_TYPE = ValidationError
