From b334f67bc3ba665f6d0b36168d1f17c4cdb94377 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Wed, 4 Mar 2020 11:11:14 +0100 Subject: [PATCH] TSVB: Add validation support for legacy filter values (#58436) (#59202) --- .../server/routes/post_vis_schema.ts | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/plugins/vis_type_timeseries/server/routes/post_vis_schema.ts b/src/plugins/vis_type_timeseries/server/routes/post_vis_schema.ts index 7893ad456e83b..3127e03ada0ef 100644 --- a/src/plugins/vis_type_timeseries/server/routes/post_vis_schema.ts +++ b/src/plugins/vis_type_timeseries/server/routes/post_vis_schema.ts @@ -63,6 +63,7 @@ const backgroundColorRulesItems = Joi.object({ const gaugeColorRulesItems = Joi.object({ gauge: stringOptionalNullable, + text: stringOptionalNullable, id: stringOptionalNullable, operator: stringOptionalNullable, value: Joi.number(), @@ -95,6 +96,18 @@ const metricsItems = Joi.object({ }) ) .optional(), + percentiles: Joi.array() + .items( + Joi.object({ + id: stringRequired, + field: stringOptionalNullable, + mode: Joi.string().allow('line', 'band'), + shade: Joi.alternatives(numberOptional, stringOptionalNullable), + value: Joi.alternatives(numberOptional, stringOptionalNullable), + percentile: stringOptionalNullable, + }) + ) + .optional(), type: stringRequired, value: stringOptionalNullable, values: Joi.array() @@ -132,10 +145,13 @@ const seriesItems = Joi.object({ ) .optional(), fill: numberOptionalOrEmptyString, - filter: Joi.object({ - query: stringRequired, - language: stringOptionalNullable, - }).optional(), + filter: Joi.alternatives( + Joi.object({ + query: stringRequired, + language: stringOptionalNullable, + }).optional(), + Joi.string().valid('') + ), formatter: stringRequired, hide_in_legend: numberIntegerOptional, hidden: Joi.boolean().optional(),