diff --git a/python_json_config/__version__.py b/python_json_config/__version__.py
index b3ddbc4..7b344ec 100644
--- a/python_json_config/__version__.py
+++ b/python_json_config/__version__.py
@@ -1,1 +1,1 @@
-__version__ = '1.1.1'
+__version__ = '1.1.2'
diff --git a/python_json_config/bin/activate b/python_json_config/bin/activate
new file mode 120000
index 0000000..a045e45
--- /dev/null
+++ b/python_json_config/bin/activate
@@ -0,0 +1,1 @@
+//anaconda/bin/activate
\ No newline at end of file
diff --git a/python_json_config/bin/conda b/python_json_config/bin/conda
new file mode 120000
index 0000000..6f1d222
--- /dev/null
+++ b/python_json_config/bin/conda
@@ -0,0 +1,1 @@
+//anaconda/bin/conda
\ No newline at end of file
diff --git a/python_json_config/bin/deactivate b/python_json_config/bin/deactivate
new file mode 120000
index 0000000..5c79faf
--- /dev/null
+++ b/python_json_config/bin/deactivate
@@ -0,0 +1,1 @@
+//anaconda/bin/deactivate
\ No newline at end of file
diff --git a/python_json_config/config_builder.py b/python_json_config/config_builder.py
index 8607631..5eb57f0 100644
--- a/python_json_config/config_builder.py
+++ b/python_json_config/config_builder.py
@@ -29,6 +29,9 @@ class ConfigBuilder(object):
     def __validate_types(self):
         for field_name, field_type in self.__validation_types.items():
             value = self.__config.get(field_name)
+            # skip optional fields that do not exist
+            if value is None:
+                continue
             assert isinstance(value, field_type), f'Config field "{field_name}" with value "{value}" is not of type {field_type}'
 
     def validate_field_value(self, field_name: str, validation_function):
@@ -45,6 +48,9 @@ class ConfigBuilder(object):
     def __validate_field_values(self):
         for field_name, validation_functions in self.__validation_functions.items():
             value = self.__config.get(field_name)
+            # skip optional fields that do not exist
+            if value is None:
+                continue
             for validation_function in validation_functions:
                 validation_result = validation_function(value)
                 error_message = f'Error validating field "{field_name}" with value "{value}"'
@@ -62,6 +68,9 @@ class ConfigBuilder(object):
     def __transform_field_values(self):
         for field_name, transformation_function in self.__transformation_functions.items():
             value = self.__config.get(field_name)
+            # skip optional fields that do not exist
+            if value is None:
+                continue
             new_value = transformation_function(value)
             self.__config.update(field_name, new_value)
 

Validation of optional fields throws errors when the field does not exist
This was an oversight in #8 
diff --git a/tests/config_builder_test.py b/tests/config_builder_test.py
index 9d9a492..6e5c8dc 100644
--- a/tests/config_builder_test.py
+++ b/tests/config_builder_test.py
@@ -142,3 +142,10 @@ class ConfigBuilderTest(TestCase):
             config.cache.name2
 
 
+    def test_optional_validation(self):
+        builder = ConfigBuilder()
+        builder.set_field_access_optional()
+        builder.validate_field_type('cache.name', str)
+        builder.validate_field_value('cache.host', 'localhost')
+        builder.transform_field_value('cache.host', lambda name: f"https://{name}")
+        builder.parse_config(self.path)

pip install -e .
parse_log_pytest
requirements.txt
pytest
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
exceptiongroup==1.2.2
iniconfig==2.1.0
jsonschema==2.6.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
-e git+https://github.com/janehmueller/python-json-config.git@1afd82e9c11a0dde17cf094fd0ca4b9b0530a614#egg=python_json_config
tomli==2.2.1

name: python-json-config
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=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - jsonschema==2.6.0
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - tomli==2.2.1
prefix: /opt/conda/envs/python-json-config

tests/config_builder_test.py::ConfigBuilderTest::test_optional_validation
tests/config_builder_test.py::ConfigBuilderTest::test_json_schema_validation tests/config_builder_test.py::ConfigBuilderTest::test_optional_access tests/config_builder_test.py::ConfigBuilderTest::test_parse tests/config_builder_test.py::ConfigBuilderTest::test_required_access tests/config_builder_test.py::ConfigBuilderTest::test_type_validation tests/config_builder_test.py::ConfigBuilderTest::test_type_validation_builder tests/config_builder_test.py::ConfigBuilderTest::test_value_transformation tests/config_builder_test.py::ConfigBuilderTest::test_value_transformation_builder tests/config_builder_test.py::ConfigBuilderTest::test_value_validation tests/config_builder_test.py::ConfigBuilderTest::test_value_validation_builder tests/config_builder_test.py::ConfigBuilderTest::test_value_validation_error_messages
python_json_config/__version__.py python_json_config/bin/activate python_json_config/bin/deactivate python_json_config/bin/conda python_json_config/config_builder.py
python_json_config/__version__.py python_json_config/bin/activate python_json_config/bin/deactivate python_json_config/bin/conda python_json_config/config_builder.py