diff --git a/rendercv/data/models/curriculum_vitae.py b/rendercv/data/models/curriculum_vitae.py index 0c8ecba7..69be7e4f 100644 --- a/rendercv/data/models/curriculum_vitae.py +++ b/rendercv/data/models/curriculum_vitae.py @@ -112,7 +112,7 @@ def get_characteristic_entry_attributes( def get_entry_type_name_and_section_validator( - entry: dict[str, str | list[str]] | str | type, entry_types: tuple[type] + entry: Optional[dict[str, str | list[str]] | str | type], entry_types: tuple[type] ) -> tuple[str, type[SectionBase]]: """Get the entry type name and the section validator based on the entry. @@ -156,6 +156,10 @@ def get_entry_type_name_and_section_validator( entry_type_name = "TextEntry" section_type = create_a_section_validator(str) + elif entry is None: + message = "The entry cannot be a null value." + raise ValueError(message) + else: # Then the entry is already initialized with a data model: entry_type_name = entry.__class__.__name__ diff --git a/tests/test_data.py b/tests/test_data.py index 3fc52664..94ef0cb5 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -967,3 +967,17 @@ def test_bold_keywords(): elif section.title == "test7": assert "**test_keyword_3**" in entry.details assert "**test_keyword_4**" in entry.details + + +def test_none_entries(): + with pytest.raises(pydantic.ValidationError): + data.RenderCVDataModel( + cv=data.CurriculumVitae( + name="John Doe", + sections={ + "test": [ + None, + ], + }, + ) + )