Replies: 1 comment 2 replies
-
Wouldn't it be simpler to do the normalisation in eg. type LogLevel string
func (l *LogLevel) UnmarshalText(data []byte) error {
level := strings.ToLower(string(data))
...
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Would a BeforeValidate hook be useful?
My own use case is that I'm setting up a logger with levels, which can be enumed DEBUG,INFO,WARN,ERROR.
The issue is that users are inputting
level=Debug
orlevel=debug
, so I would like to normalize that input to uppercase before the Validation is run.I can PR this in if anyone else finds it useful.
Beta Was this translation helpful? Give feedback.
All reactions