-
Notifications
You must be signed in to change notification settings - Fork 117
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
Check allowed values for fields #771
Conversation
|
||
// ensureAllowedValues validates that the document's field value | ||
// is one of the allowed values. | ||
func ensureAllowedValues(key, value string, allowedValues AllowedValues) error { |
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.
nit: in theory, you don't need to pass key
here as it's just used to render the error message :)
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.
Umm, but error message is rendered here, key
is used in this function for that.
I would be fine with refactoring this error generation, but in a different PR, making the other ensure
methods consistent with this.
Blocked till elastic/integrations#3016 is solved. |
🌐 Coverage report
|
145a797
to
f40d122
Compare
I have moved the changes to check values in arrays to #835, so we can start benefiting of this in other cases as with IP validation (elastic/integrations#3408). |
Opening this for final review as blockers in elastic/integrations#3016 are close to be completed. @mtojek could you please take another look? |
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.
Ship it!
Fields can include a list of allowed values. Check that the values of
these fields are between the allowed ones.
For arrays, validation is now done for all fields, as we not only need
to validate their type but also their values.
Part of #615.