diff --git a/toscaparser/dataentity.py b/toscaparser/dataentity.py index 3a9b9fa..507c899 100644 --- a/toscaparser/dataentity.py +++ b/toscaparser/dataentity.py @@ -122,6 +122,9 @@ class DataEntity(object): If type is list or map, validate its entry by entry_schema(if defined) If type is a user-defined complex datatype, custom_def is required. ''' + from toscaparser.functions import is_function + if is_function(value): + return value if type == Schema.STRING: return validateutils.validate_string(value) elif type == Schema.INTEGER: diff --git a/toscaparser/tests/test_datatypes.py b/toscaparser/tests/test_datatypes.py index 62e4362..0a6cfe0 100644 --- a/toscaparser/tests/test_datatypes.py +++ b/toscaparser/tests/test_datatypes.py @@ -504,3 +504,14 @@ class DataTypeTest(TestCase): 'value of type "tosca.datatypes.Credential" contains' ' unknown field "some_field". Refer to the definition' ' to verify valid values'), err.__str__()) + + def test_functions_datatype(self): + value_snippet = ''' + admin_credential: + user: username + token: { get_input: password } + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('tosca.datatypes.Credential', + value.get('admin_credential')) + self.assertIsNotNone(data.validate())