Open layxyer opened 2 weeks ago
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord
@layxyer What do you mean by but the binding validators provided by version 3 lack context information
?
Btw you can use this, to check if en
is in the headers.
ctx.AcceptsLanguages("en")
This will return "en"
, if the request has the value in the Header.
@layxyer你的意思是什么
but the binding validators provided by version 3 lack context information
?顺便说一句,您可以使用它来检查是否
en
在标题中。ctx.AcceptsLanguages("en")
"en"
如果请求的 Header 中有值,则将返回。 I mean the validator method does not have a ctx parameter, so it cannot obtain language information.
@layxyer你的意思是
but the binding validators provided by version 3 lack context information
?顺便说一句,你可以用它来检查是否
en
在标题中。ctx.AcceptsLanguages("en")
"en"
如果请求的 Header 包含值,则将返回。
I added the ctx parameter to the Validate method in the example code, but in fact, the official method does not include this parameter.
@layxyer 我认为在现在的阶段, 你只能用额外的方法进行参数的校验和替换了
I think at this situatiom, you can only use additional methods for parameter checking and substitution
Question Description
I tried some methods, but the binding validators provided by version 3 lack context information, making it impossible to obtain the user's preferred language information and perform internationalization translations during validation. Although translation can be done in each route, this approach is somewhat repetitive and cumbersome.It would be great if a context parameter could be added to the validator interface, or if there is a better way that I haven't discovered yet.
Code Snippet (optional)
Checklist: