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

Introducing OneOf and NoneOf #42

Merged
merged 9 commits into from
Jun 23, 2022
Merged

Introducing OneOf and NoneOf #42

merged 9 commits into from
Jun 23, 2022

Conversation

detro
Copy link
Contributor

@detro detro commented Jun 21, 2022

Closes #7
Closes #8
Closes #9

Validators added here, per package:

  • int64validator
    • OneOf(int64...), NoneOf(int64...)
  • float64validator
    • OneOf(float64...), NoneOf(float64...)
  • numbervalidator
    • OneOf(*big.Float...), NoneOf(*big.Float...)
  • stringvalidator
    • OneOf(bool, float64...), NoneOf(bool, float64...)
    • NOTE: the extra bool parameter is to enable/disable case sensitivity

The validators are designed to restrict use to the primitive types, and it will throw errors if used against any collection type.

Implementation for all but the stringvalidator package is provided by the primitivevalidator package, that holds the bulk of the logic.

@detro detro requested a review from a team as a code owner June 21, 2022 16:24
@detro detro added this to the v0.3.0 milestone Jun 21, 2022
Copy link
Contributor

@bendbennett bendbennett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
Left a comment but I'm not sure it's a significant concern.
I've only reviewed genericvalidator package as you mentioned.

genericvalidator/acceptable_values_validator.go Outdated Show resolved Hide resolved
@bflad bflad added the enhancement New feature or request label Jun 22, 2022
Copy link
Contributor

@bendbennett bendbennett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Couple of minor comments but nothing blocking. Guess the only question I have is around naming of the internal pkg, for instance are we going to use primitivevalidator and collectionvalidator, complexvalidator etc.

.changelog/42.txt Outdated Show resolved Hide resolved
float64validator/at_least.go Outdated Show resolved Hide resolved
helpers/validatordiag/diag.go Outdated Show resolved Hide resolved
internal/primitivevalidator/none_of_test.go Show resolved Hide resolved
@detro
Copy link
Contributor Author

detro commented Jun 23, 2022

About the internal/ package naming, I don't know what's best to do. I picked primitivevalidator just because in the FW codebase, the attr.Type implementation for them is of type primitive. And they are "Golang primitives".

For the collections, I don't have a better name 🤷 , so I'd go for something like collection*, or bunchofstuff* 😄

@detro detro merged commit 668b4ce into main Jun 23, 2022
@detro detro deleted the detro/one-of_none-of branch June 23, 2022 14:34
bflad added a commit that referenced this pull request Jun 29, 2022
bflad added a commit that referenced this pull request Jun 29, 2022
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
3 participants