Add String Variant Validator
This feature basically provides a simple StringValidator
for string variants (~string
). In the current latest version, if we need a validator for the type VariantExample string
, which is a string variant, we have to convert VariantExample
to a string
in order to use the StringValidator
. These changes add a new API that reuses the StringValidator
rules for string variants without any conversion.
Before:
type Variant string
const (
VariantA Variant = "A"
VariantB Variant = "B"
)
var validator = goval.String().In(string(VariantA), string(VariantB))
After:
type Variant string
const (
VariantA Variant = "A"
VariantB Variant = "B"
)
var validator = goval.StringVariant[Variant]().In(VariantA, VariantB)