diff --git a/nomad/metainfo/data_type.py b/nomad/metainfo/data_type.py index 282a0dda20a71ff5a2e27b6d0f7724529f03dcd8..facd79daf6b4dfdefb3e60038c22139359c6730d 100644 --- a/nomad/metainfo/data_type.py +++ b/nomad/metainfo/data_type.py @@ -988,9 +988,16 @@ class Enum(NonPrimitive): return len(self._list) def _validate_value(self, value: str): - if value not in self: - raise ValueError(f'{value} is not a value of this enumeration.') - return value + if value in self: + return value + + # this is to account for the faulty values that exist in the database + # the faulty values are the ones look like `enumClass.enumValue` + # that are generated by calling `str()` on the enum fields + if (new_value := value.split('.')[-1]) in self: + return new_value + + raise ValueError(f'{value} is not a value of this enumeration.') def set_description(self, value: str, description: str): self._descriptions[self._validate_value(value)] = description