You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Hertz integrates with go-tagexpr for paramater binding and validation. However, go-tagexpr itself is poorly documented, therefore it becomes difficult for people who are new to hertz to add their first vd tag.
Describe the solution you'd like
I would recommand add examples for the following tags:
length validation for string and list len($)>0
regex pattern match for string regexp('^\\w*$')"
value validation for numertic field $>0
validation for pointer field num==nil || num>0
validation for enum types type=="hello" || type == "world"
custom error message msg:'C must be false when S.A>0'"
I have used these tags extensively in production and these tags should cover a widely range of use cases.
Also, we could provide a example of defining vd tags in idl, this should also helps.
Describe alternatives you've considered
Alternative, we can add these examples to reference if it doesn't fit into the scope of Binding and validate
Additional context
I have been used vd for almost 2 years. I constantly found myself confused and frustared with go-tagexpr's documentation. Hopefully, with these examples, hertz users can get started with vd with much less pain.
The text was updated successfully, but these errors were encountered:
Haswf
changed the title
doc: provide more examples for binding and validate
doc: provide more examples for parameter validation
Mar 6, 2023
@Haswf We have refactored the parameter binding and validation capabilities (#541), and the new validation function will use "go-playground/validator".
The "go-tagexpr" will be moved to "hertz-contrib".
You can write a new example after the new version is released
Is your feature request related to a problem? Please describe.
Hertz integrates with go-tagexpr for paramater binding and validation. However, go-tagexpr itself is poorly documented, therefore it becomes difficult for people who are new to hertz to add their first vd tag.
Describe the solution you'd like
I would recommand add examples for the following tags:
len($)>0
regexp('^\\w*$')"
$>0
num==nil || num>0
type=="hello" || type == "world"
msg:'C must be false when S.A>0'"
I have used these tags extensively in production and these tags should cover a widely range of use cases.
Also, we could provide a example of defining
vd
tags in idl, this should also helps.Describe alternatives you've considered
Alternative, we can add these examples to reference if it doesn't fit into the scope of Binding and validate
Additional context
I have been used vd for almost 2 years. I constantly found myself confused and frustared with go-tagexpr's documentation. Hopefully, with these examples, hertz users can get started with vd with much less pain.
The text was updated successfully, but these errors were encountered: