This PR adds a feature to allow selecting struct fields or map values for further validation.
This is useful when trying to apply validation tags to a wrapped value without having to use RegisterCustomTypeFunc with all possible types. When using the new sql.Null for example.
Usage
The usage would be similar to that of the dive tag in the sense that validation tags can be specified for the whole field or the selected field depending on whether they are placed before or after the select tag.
type MyStruct struct {
Field sql.Null[uint] `validate:"omitempty,select=V,gt=10"`
}
Limitations
Only a single select field can be specified.
Select fields do not support custom names.
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.217% (+0.009%) from 74.208%
when pulling 7eb58afab34a368220d0a7ecbbc9c74e983d6c0b on MysteriousPotato:main
into a0f74b0fb2a7ae1750c0f0b0a49550d8b6e2e708 on go-playground:master.
Fixes Or Enhances
This PR adds a feature to allow selecting struct fields or map values for further validation.
This is useful when trying to apply validation tags to a wrapped value without having to use
RegisterCustomTypeFunc
with all possible types. When using the newsql.Null
for example.Usage
The usage would be similar to that of the
dive
tag in the sense that validation tags can be specified for the whole field or the selected field depending on whether they are placed before or after theselect
tag.Limitations
Make sure that you've checked the boxes below before you submit PR:
@go-playground/validator-maintainers