Open MashinaMashina opened 6 months ago
Hi @MashinaMashina ,
Thanks for the PR. I'm not sure if putting the env name into the error description is the best idea, since env
is an optional tag. I'm thinking about something like a path to the variable in the structure.
Not saying your solution is bad or something, it is just not comprehensive. Building a path will solve this problem for all kinds of fields, even lists and maps.
In my head, it looks like a simplified JSONPath format. Something like scruct_field1/list_field2[0]/map_field3[key]/field4
.
What do you think?
@ilyakaznacheev I added the path to the field with which the error occurred. I tried to do it using []string, but there are rewriting errors in slice or the code becomes too complicated using the copy function.
Example error string: field "Database.Host" is required but the value is not provided
@ilyakaznacheev Could you please merge this PR?
@ilyakaznacheev what about this PR?
With several nested structures with identical fields, there is no way to understand which error occurred.
This MP, without changing backward compatibility, adds a structure from which you can find out the field name.
If the community wishes, you can include the name in the error message.