-
Notifications
You must be signed in to change notification settings - Fork 329
ValidationScheme implements pflag.Value and json.Marshaler/Unmarshaler interfaces #807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
ValidationScheme implements pflag.Value and json.Marshaler/Unmarshaler interfaces #807
Conversation
70453fd
to
06cb330
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why you're removing the fmt.Stringer
assertion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements additional interfaces for the ValidationScheme
type to support JSON marshaling/unmarshaling and command-line flag parsing. The changes enhance the ValidationScheme
type by making it compatible with JSON serialization and pflag.Value interface for CLI usage.
Key changes:
- Added JSON marshaling and unmarshaling support for
ValidationScheme
- Implemented pflag.Value interface methods (
Set
andType
) - Refactored existing YAML unmarshaling to use the new
Set
method for consistency
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
model/metric.go | Implements JSON marshaling/unmarshaling and pflag.Value interface methods for ValidationScheme |
model/metric_test.go | Adds comprehensive test coverage for new JSON and pflag functionality |
|
||
// Set implements the pflag.Value interface. | ||
func (s *ValidationScheme) Set(text string) error { | ||
switch text { | ||
case "": | ||
// Don't change the value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment 'Don't change the value' is misleading for an empty string input. When Set() is called with an empty string, it should set the value to UnsetValidation, not leave it unchanged. Either update the logic to set *s = UnsetValidation or clarify the comment to explain why empty strings preserve the current value.
// Don't change the value. | |
// Set to UnsetValidation for empty string input. | |
*s = UnsetValidation |
Copilot uses AI. Check for mistakes.
06cb330
to
8454829
Compare
…er/Unmarshaler interfaces Signed-off-by: Julius Hinze <[email protected]>
8454829
to
2e9eb8f
Compare
No description provided.