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

config-schema incorrectly fails validation on optional props on objects #55966

Closed
gmmorris opened this issue Jan 27, 2020 · 1 comment · Fixed by #55932
Closed

config-schema incorrectly fails validation on optional props on objects #55966

gmmorris opened this issue Jan 27, 2020 · 1 comment · Fixed by #55932
Assignees
Labels
blocker Feature:New Platform Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@gmmorris
Copy link
Contributor

Kibana version:
7.7

Describe the bug:
I’ve encountered an issue in config-schema.
We have a key that’s optional on an object and for some reason, it doesn't pass validation.

Steps to reproduce:

Just put this in your test suite.

test('should allow optional nested objects', () => {
  const type = schema.object({
    name: schema.maybe(
      schema.object({
        type: schema.string(),
        id: schema.string(),
      })
    ),
  });

  expect(type.validate({})).toEqual({});
});

This test, weirdly, doesn’t pass.

It throws this:

[name.type]: expected value of type [string] but got [undefined]

But this one does:

test('should allow optional nested objects', () => {
  const type = schema.object({
    name: schema.maybe(schema.string()),
  });

  expect(type.validate({})).toEqual({});
});

Expected behavior:
Should pass validation.

@gmmorris gmmorris added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.7.0 labels Jan 27, 2020
@elasticmachine
Copy link
Contributor

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

@joshdover joshdover self-assigned this Jan 28, 2020
@joshdover joshdover added this to In progress in kibana-core [DEPRECATED] Jan 28, 2020
kibana-core [DEPRECATED] automation moved this from In progress to Done (7.7) Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Feature:New Platform Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
Development

Successfully merging a pull request may close this issue.

4 participants