In an application where we let a user configure custom fields and validation, we want to make sure that the tag associated with the field is valid before using it (because the validation library panics if the tag is invalid, which is fine when the library is used with struct annotations, but not very nice when using methods Var, VarCtx, VarWithValue and VarWithValueCtx directly)
in order to validate a user validation tag input, I propose a new method that handles tag validation and returns an error if there is an invalid tag, allowing a library user to handle this error nicely.
The benefits of adding this here instead of in our codebase is that the tag list is always up to date and it handles custom validators too.
Make sure that you've checked the boxes below before you submit PR:
[x] Tests exist or have been written that cover this particular change.
coverage: 74.184% (+0.01%) from 74.172%
when pulling cbdba6fdf0495c130d5d7744a91ef934654c2dab on xgourmandin:master
into b328f72e15814aba56e018c06675b8d679ad6e90 on go-playground:master.
Enhances
Use case description :
In an application where we let a user configure custom fields and validation, we want to make sure that the tag associated with the field is valid before using it (because the validation library panics if the tag is invalid, which is fine when the library is used with struct annotations, but not very nice when using methods
Var
,VarCtx
,VarWithValue
andVarWithValueCtx
directly)in order to validate a user validation tag input, I propose a new method that handles tag validation and returns an error if there is an invalid tag, allowing a library user to handle this error nicely.
The benefits of adding this here instead of in our codebase is that the tag list is always up to date and it handles custom validators too.
Make sure that you've checked the boxes below before you submit PR:
@go-playground/validator-maintainers