diff --git a/typesystem/base.py b/typesystem/base.py
index bd15068..def115c 100644
--- a/typesystem/base.py
+++ b/typesystem/base.py
@@ -78,6 +78,10 @@ class Message:
             and self.end_position == other.end_position
         )
 
+    def __hash__(self) -> int:
+        ident = (self.code, tuple(self.index))
+        return hash(ident)
+
     def __repr__(self) -> str:
         class_name = self.__class__.__name__
         index_str = f", index={self.index!r}" if self.index else ""
@@ -183,6 +187,10 @@ class BaseError(Mapping, Exception):
     def __eq__(self, other: typing.Any) -> bool:
         return isinstance(other, ValidationError) and self._messages == other._messages
 
+    def __hash__(self) -> int:
+        ident = tuple(hash(m) for m in self._messages)
+        return hash(ident)
+
     def __repr__(self) -> str:
         class_name = self.__class__.__name__
         if len(self._messages) == 1 and not self._messages[0].index:

ValidationError can't be shown with `traceback.print_exc()` in Python 3.6
Consider the following code:

```python
import traceback
import typesystem

try:
    typesystem.Integer().validate("hello")
except typesystem.ValidationError:
    traceback.print_exc()
```

Because of an issue with Python 3.6 discussed in [issue 28803](https://bugs.python.org/issue28603), since `ValidationError` implements `__eq__` but not `__hash__` it is not hashable and `print_exc()` fails to process it correctly.

```
TypeError: unhashable type: 'ValidationError'
```

(Full traceback available [here](https://travis-ci.org/bocadilloproject/bocadillo/jobs/513086149))

Looks like we'd need to implement `ValidationError.__hash__()` to fix this.
diff --git a/tests/test_fields.py b/tests/test_fields.py
index b908a66..56f24e6 100644
--- a/tests/test_fields.py
+++ b/tests/test_fields.py
@@ -825,3 +825,9 @@ def test_error_messages_interface():
     validator = Integer()
     value, error = validator.validate_or_error("abc")
     assert error.messages() == [Message(text="Must be a number.", code="type")]
+
+
+def test_validation_error_is_hashable():
+    validator = Integer()
+    _, error = validator.validate_or_error("abc")
+    hash(error)

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov
3.8
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
autoflake==2.3.1
babel==2.17.0
backrefs==5.7.post1
black==24.8.0
certifi==2025.1.31
charset-normalizer==3.4.1
click==8.1.8
codecov==2.1.13
colorama==0.4.6
coverage==7.6.1
exceptiongroup==1.2.2
ghp-import==2.1.0
idna==3.10
importlib_metadata==8.5.0
iniconfig==2.1.0
isort==5.13.2
Jinja2==3.1.6
Markdown==3.7
MarkupSafe==2.1.5
mergedeep==1.3.4
mkdocs==1.6.1
mkdocs-get-deps==0.2.0
mkdocs-material==9.6.10
mkdocs-material-extensions==1.3.1
mypy==1.14.1
mypy-extensions==1.0.0
packaging==24.2
paginate==0.5.7
pathspec==0.12.1
platformdirs==4.3.6
pluggy==1.5.0
pyflakes==3.2.0
Pygments==2.19.1
pymdown-extensions==10.14.3
pytest==8.3.5
pytest-cov==5.0.0
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.2
pyyaml_env_tag==0.1
requests==2.32.3
six==1.17.0
tomli==2.2.1
-e git+https://github.com/encode/typesystem.git@453c6fb05a43efe26ffeb476ca311a199a4fb704#egg=typesystem
typing_extensions==4.13.0
urllib3==2.2.3
watchdog==4.0.2
zipp==3.20.2

name: typesystem
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=24.2=py38h06a4308_0
  - python=3.8.20=he870216_0
  - readline=8.2=h5eee18b_0
  - setuptools=75.1.0=py38h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.44.0=py38h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - autoflake==2.3.1
      - babel==2.17.0
      - backrefs==5.7.post1
      - black==24.8.0
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - click==8.1.8
      - codecov==2.1.13
      - colorama==0.4.6
      - coverage==7.6.1
      - exceptiongroup==1.2.2
      - ghp-import==2.1.0
      - idna==3.10
      - importlib-metadata==8.5.0
      - iniconfig==2.1.0
      - isort==5.13.2
      - jinja2==3.1.6
      - markdown==3.7
      - markupsafe==2.1.5
      - mergedeep==1.3.4
      - mkdocs==1.6.1
      - mkdocs-get-deps==0.2.0
      - mkdocs-material==9.6.10
      - mkdocs-material-extensions==1.3.1
      - mypy==1.14.1
      - mypy-extensions==1.0.0
      - packaging==24.2
      - paginate==0.5.7
      - pathspec==0.12.1
      - platformdirs==4.3.6
      - pluggy==1.5.0
      - pyflakes==3.2.0
      - pygments==2.19.1
      - pymdown-extensions==10.14.3
      - pytest==8.3.5
      - pytest-cov==5.0.0
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pyyaml==6.0.2
      - pyyaml-env-tag==0.1
      - requests==2.32.3
      - six==1.17.0
      - tomli==2.2.1
      - typing-extensions==4.13.0
      - urllib3==2.2.3
      - watchdog==4.0.2
      - zipp==3.20.2
prefix: /opt/conda/envs/typesystem

tests/test_fields.py::test_validation_error_is_hashable
tests/test_fields.py::test_string tests/test_fields.py::test_integer tests/test_fields.py::test_float tests/test_fields.py::test_decimal tests/test_fields.py::test_number tests/test_fields.py::test_boolean tests/test_fields.py::test_choice tests/test_fields.py::test_object tests/test_fields.py::test_array tests/test_fields.py::test_date tests/test_fields.py::test_time tests/test_fields.py::test_datetime tests/test_fields.py::test_uuid tests/test_fields.py::test_union tests/test_fields.py::test_const tests/test_fields.py::test_errors_dict_interface tests/test_fields.py::test_error_messages_interface
typesystem/base.py
typesystem/base.py