For example, with this change, an "enum" type can validate that the value to be encoded or the just-decoded value is a valid enum value, just by defining a single method:
func (e Enum) ValidForTLS() error {
if (e == KnownEnumValue0) || (e == KnownEnumValue0) || ... {
return nil
}
return fmt.Errorf("Unknown enum value")
}
This facility could also, of course, be used to validate more advanced types.
For example, with this change, an "enum" type can validate that the value to be encoded or the just-decoded value is a valid enum value, just by defining a single method:
This facility could also, of course, be used to validate more advanced types.