Skip to content
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

Feat:(issue_1960) make defaults validation optional #1961

Merged
merged 1 commit into from
Aug 25, 2024

Conversation

dearchap
Copy link
Contributor

What type of PR is this?

(REQUIRED)

  • documentation
  • feature

What this PR does / why we need it:

(REQUIRED)

The feature allows default validation to be optional.

Which issue(s) this PR fixes:

(REQUIRED)

Fixes #1960

Special notes for your reviewer:

(fill-in or delete this section)

Testing

(fill-in or delete this section)

make test

Release Notes

(REQUIRED)

Defaults validation is optional(false). Validation of defaults, values from env can be enabled by setting ValidateDefaults to true

@dearchap dearchap requested a review from a team as a code owner August 10, 2024 20:15
@dearchap
Copy link
Contributor Author

@urfave/cli I'm wondering if we need to validate values from ValueSources(like Env, File etc) but not the default that the user sets explicitly via Value . Thoughts ?

@Juneezee
Copy link
Member

I'm wondering if we need to validate values from ValueSources(like Env, File etc) but not the default that the user sets explicitly via Value . Thoughts ?

I believe this would be a valuable feature. We could potentially create a Validator struct to accommodate future extensions, such as:

type Validator[T any] struct {
	ValidateFunc     func(T) error `json:"-"`
	ValidateDefaults bool          `json:"validateDefaults"`
	ValidateSources  bool          `json:"validateSources"`
}

@dearchap dearchap merged commit cf9bcea into urfave:main Aug 25, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strange .Validator behavior
4 participants