Validation function to ensure that data structure matches a template structure