def _add_example_helper(self, example):
<EOL>for label, example_field in example.fields.items():<EOL><INDENT>if not any(label == f.name for f in self.all_fields):<EOL><INDENT>raise InvalidSpec(<EOL>"<STR_LIT>" %<EOL>(self.name, label),<EOL>example_field.lineno, example_field.path,<EOL>)<EOL><DEDENT><DEDENT>for field in self.all_fields:<EOL><INDENT>if field.name in example.fields:<EOL><INDENT>example_field = example.fields[field.name]<EOL>try:<EOL><INDENT>field.data_type.check_example(example_field)<EOL><DEDENT>except InvalidSpec as e:<EOL><INDENT>e.msg = "<STR_LIT>".format(<EOL>field.name, e.msg)<EOL>raise<EOL><DEDENT><DEDENT>elif field.has_default or isinstance(field.data_type, Nullable):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>raise InvalidSpec(<EOL>"<STR_LIT>" % field.name,<EOL>example.lineno, example.path)<EOL><DEDENT><DEDENT>self._raw_examples[example.label] = example<EOL>
Validates examples for structs without enumerated subtypes.