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

Fix maybe behavior with object type #55932

Merged
merged 11 commits into from
Feb 14, 2020

Conversation

joshdover
Copy link
Contributor

@joshdover joshdover commented Jan 24, 2020

Summary

Fixes #55966

This makes a couple fundamental changes to how ObjectType and MaybeType work in conjunction with one another.

  • First, it makes the default option with schema.maybe actually be undefined rather than calling Joi's default() method which does something else -- populates the default options for all subkeys of an object.
  • Second, it adds a applyDefaults option to schema.object that is true by default. This will automatically populate the subkeys of the object if nothing is defined for that key on the input. If the key does not have a default, the validation will fail. applyDefaults is true by default, but can be toggled false if this behavior is not desired in some cases.

This aligns the functionality to be more similar to Joi and what developers tend to expect to happen. I did have to correct a handful of existing config schemas, but as far as I can tell, this improved their readability.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@joshdover joshdover force-pushed the np/fix-maybe-object branch 3 times, most recently from 32c974f to 469b572 Compare February 5, 2020 23:05
@joshdover joshdover added Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.7.0 labels Feb 5, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

@joshdover joshdover added this to Code review in kibana-core [DEPRECATED] via automation Feb 5, 2020
@joshdover joshdover marked this pull request as ready for review February 5, 2020 23:11
@joshdover joshdover requested review from a team as code owners February 5, 2020 23:11
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@joshdover joshdover requested a review from a team as a code owner February 10, 2020 20:35
Copy link
Member

@pmuellr pmuellr left a comment

Choose a reason for hiding this comment

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

the changes to event_log LGTM

@joshdover
Copy link
Contributor Author

@elasticmachine merge upstream

@joshdover joshdover closed this Feb 14, 2020
kibana-core [DEPRECATED] automation moved this from Code review to Done (7.7) Feb 14, 2020
@joshdover joshdover reopened this Feb 14, 2020
@joshdover
Copy link
Contributor Author

@elasticmachine merge upstream

@joshdover
Copy link
Contributor Author

@elasticmachine retest

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@joshdover joshdover merged commit 6bd09d6 into elastic:master Feb 14, 2020
kibana-core [DEPRECATED] automation moved this from Done (7.7) to Needs Backport Feb 14, 2020
@joshdover joshdover deleted the np/fix-maybe-object branch February 14, 2020 19:07
joshdover added a commit to joshdover/kibana that referenced this pull request Feb 14, 2020
@joshdover joshdover moved this from Needs Backport to Done (7.7) in kibana-core [DEPRECATED] Feb 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.7.0
Projects
Development

Successfully merging this pull request may close these issues.

config-schema incorrectly fails validation on optional props on objects
8 participants