diff --git a/docs/development/core/server/kibana-plugin-server.routeconfig.validate.md b/docs/development/core/server/kibana-plugin-server.routeconfig.validate.md
index c69ff4cbb5af2a..d5edabffa40b89 100644
--- a/docs/development/core/server/kibana-plugin-server.routeconfig.validate.md
+++ b/docs/development/core/server/kibana-plugin-server.routeconfig.validate.md
@@ -14,7 +14,7 @@ validate: RouteValidatorFullConfig
| false;
## Remarks
-You \*must\* specify a validation schema to be able to read: - url path segments - request query - request body To opt out of validating the request, specify `validate: false`. In this case request params, query, and body will be \*\*empty\*\* objects and have no access to raw values. In some cases you may want to use another validation library. To do this, you need to instruct the `@kbn/config-schema` library to output \*\*non-validated values\*\* with setting schema as `schema.object({}, { allowUnknowns: true })`;
+You \*must\* specify a validation schema to be able to read: - url path segments - request query - request body To opt out of validating the request, specify `validate: false`. In this case request params, query, and body will be \*\*empty\*\* objects and have no access to raw values. In some cases you may want to use another validation library. To do this, you need to instruct the `@kbn/config-schema` library to output \*\*non-validated values\*\* with setting schema as `schema.object({}, { unknowns: 'allow' })`;
## Example
diff --git a/packages/kbn-config-schema/README.md b/packages/kbn-config-schema/README.md
index 8719a2ae558abe..a4f2c1f6458cfa 100644
--- a/packages/kbn-config-schema/README.md
+++ b/packages/kbn-config-schema/README.md
@@ -239,7 +239,7 @@ __Output type:__ `{ [K in keyof TProps]: TypeOf } as TObject`
__Options:__
* `defaultValue: TObject | Reference | (() => TObject)` - defines a default value, see [Default values](#default-values) section for more details.
* `validate: (value: TObject) => string | void` - defines a custom validator function, see [Custom validation](#custom-validation) section for more details.
- * `allowUnknowns: boolean` - indicates whether unknown object properties should be allowed. It's `false` by default.
+ * `unknowns: 'allow' | 'ignore' | 'forbid'` - indicates whether unknown object properties should be allowed, ignored, or forbidden. It's `forbid` by default.
__Usage:__
```typescript
@@ -250,7 +250,7 @@ const valueSchema = schema.object({
```
__Notes:__
-* Using `allowUnknowns` is discouraged and should only be used in exceptional circumstances. Consider using `schema.recordOf()` instead.
+* Using `unknowns: 'allow'` is discouraged and should only be used in exceptional circumstances. Consider using `schema.recordOf()` instead.
* Currently `schema.object()` always has a default value of `{}`, but this may change in the near future. Try to not rely on this behaviour and specify default value explicitly or use `schema.maybe()` if the value is optional.
* `schema.object()` also supports a json string as input if it can be safely parsed using `JSON.parse` and if the resulting value is a plain object.
diff --git a/packages/kbn-config-schema/src/types/object_type.test.ts b/packages/kbn-config-schema/src/types/object_type.test.ts
index 41025046e282d0..5ddefcf261e24b 100644
--- a/packages/kbn-config-schema/src/types/object_type.test.ts
+++ b/packages/kbn-config-schema/src/types/object_type.test.ts
@@ -276,10 +276,10 @@ test('individual keys can validated', () => {
);
});
-test('allow unknown keys when allowUnknowns = true', () => {
+test('allow unknown keys when unknowns = `allow`', () => {
const type = schema.object(
{ foo: schema.string({ defaultValue: 'test' }) },
- { allowUnknowns: true }
+ { unknowns: 'allow' }
);
expect(
@@ -292,10 +292,10 @@ test('allow unknown keys when allowUnknowns = true', () => {
});
});
-test('allowUnknowns = true affects only own keys', () => {
+test('unknowns = `allow` affects only own keys', () => {
const type = schema.object(
{ foo: schema.object({ bar: schema.string() }) },
- { allowUnknowns: true }
+ { unknowns: 'allow' }
);
expect(() =>
@@ -308,10 +308,10 @@ test('allowUnknowns = true affects only own keys', () => {
).toThrowErrorMatchingInlineSnapshot(`"[foo.baz]: definition for this key is missing"`);
});
-test('does not allow unknown keys when allowUnknowns = false', () => {
+test('does not allow unknown keys when unknowns = `forbid`', () => {
const type = schema.object(
{ foo: schema.string({ defaultValue: 'test' }) },
- { allowUnknowns: false }
+ { unknowns: 'forbid' }
);
expect(() =>
type.validate({
@@ -320,10 +320,10 @@ test('does not allow unknown keys when allowUnknowns = false', () => {
).toThrowErrorMatchingInlineSnapshot(`"[bar]: definition for this key is missing"`);
});
-test('allow and remove unknown keys when ignoreUnknowns = true', () => {
+test('allow and remove unknown keys when unknowns = `ignore`', () => {
const type = schema.object(
{ foo: schema.string({ defaultValue: 'test' }) },
- { ignoreUnknowns: true }
+ { unknowns: 'ignore' }
);
expect(
@@ -335,10 +335,10 @@ test('allow and remove unknown keys when ignoreUnknowns = true', () => {
});
});
-test('ignoreUnknowns = true affects only own keys', () => {
+test('unknowns = `ignore` affects only own keys', () => {
const type = schema.object(
{ foo: schema.object({ bar: schema.string() }) },
- { ignoreUnknowns: true }
+ { unknowns: 'ignore' }
);
expect(() =>
@@ -350,15 +350,3 @@ test('ignoreUnknowns = true affects only own keys', () => {
})
).toThrowErrorMatchingInlineSnapshot(`"[foo.baz]: definition for this key is missing"`);
});
-
-test('does not allow unknown keys when ignoreUnknowns = false', () => {
- const type = schema.object(
- { foo: schema.string({ defaultValue: 'test' }) },
- { ignoreUnknowns: false }
- );
- expect(() =>
- type.validate({
- bar: 'baz',
- })
- ).toThrowErrorMatchingInlineSnapshot(`"[bar]: definition for this key is missing"`);
-});
diff --git a/packages/kbn-config-schema/src/types/object_type.ts b/packages/kbn-config-schema/src/types/object_type.ts
index 9568edcf39dfdf..d30c9921169425 100644
--- a/packages/kbn-config-schema/src/types/object_type.ts
+++ b/packages/kbn-config-schema/src/types/object_type.ts
@@ -30,23 +30,16 @@ export type TypeOf