Closed lll-lll-lll-lll closed 6 months ago
Hi @lll-lll-lll-lll, thanks. It seems like this is intentional, but I honestly do not recall the reasons behind the choice because it has been a while since I submitted the PR. Maybe it was because default
was considered as something optional and therefore should not break the decoding, no matter what. There is also a test case for this behavior: https://github.com/gorilla/schema/blob/main/decoder_test.go#L2217
I like the idea of failing when a default value that do not match the type is provided. This would enforce correctness and notify when some unexpected value is used. It's certainly a plus.
@AlexVulaj, @jaitaiwan what do you think ?
I'm in agreement with @zak905 here - I think it's better to handle cases with an unexpected value. Please feel free to submit a PR for this change and tag me in it, thanks!
Thank you, I will try to make a PR!
Is there an existing feature request for this?
Is your feature request related to a problem? Please describe.
Question
when a struct field is a slice with two different element types, the current implementation seems to ignore element of the wrong type. Is this intentional behavior? Is there no error handling for this scenario?
Implementation
https://github.com/gorilla/schema/blob/main/decoder.go#L130-L137
example
Describe the solution that you would like.
Describe alternatives you have considered.
No response
Anything else?
No response