def validate_str_fields(self, fields, optional, messages):
for field_str in fields:<EOL><INDENT>field = getattr(self, field_str)<EOL>if field is not None:<EOL><INDENT>attr = getattr(field, '<STR_LIT>', None)<EOL>if not callable(attr):<EOL><INDENT>messages = messages + [<EOL>'<STR_LIT>'.format(field)<EOL>]<EOL><DEDENT><DEDENT>elif not optional:<EOL><INDENT>messages = messages + [<EOL>'<STR_LIT>'.format(field_str)<EOL>]<EOL><DEDENT><DEDENT>return messages<EOL>
Helper for validate_mandatory_str_field and
        validate_optional_str_fields