def _check_single_data_type()

in hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/commit_to_hugegraph.py [0:0]


    def _check_single_data_type(self, data_type: str, value) -> bool:
        if data_type == PropertyDataType.BOOLEAN.value:
            return isinstance(value, bool)
        if data_type in (PropertyDataType.BYTE.value, PropertyDataType.INT.value, PropertyDataType.LONG.value):
            return isinstance(value, int)
        if data_type in (PropertyDataType.FLOAT.value, PropertyDataType.DOUBLE.value):
            return isinstance(value, float)
        if data_type in (PropertyDataType.TEXT.value, PropertyDataType.UUID.value):
            return isinstance(value, str)
        # TODO: check ok below
        if data_type == PropertyDataType.DATE.value: # the format should be "yyyy-MM-dd"
            import re
            return isinstance(value, str) and re.match(r'^\d{4}-\d{2}-\d{2}$', value)
        raise ValueError(f"Unknown/Unsupported data type: {data_type}")