From 348b55d590b942643bf842f7b36a2956d3d4bb53 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 16 Aug 2021 14:36:35 -0400 Subject: [PATCH] Add empty tag validation to cases (#108699) (#108728) Co-authored-by: Pablo Machado --- x-pack/plugins/cases/public/common/translations.ts | 4 ++++ .../cases/public/components/create/schema.tsx | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/cases/public/common/translations.ts b/x-pack/plugins/cases/public/common/translations.ts index 62d0fdeb4dc91..dc4fe9fd299f5 100644 --- a/x-pack/plugins/cases/public/common/translations.ts +++ b/x-pack/plugins/cases/public/common/translations.ts @@ -129,6 +129,10 @@ export const TAGS_HELP = i18n.translate('xpack.cases.createCase.fieldTagsHelpTex 'Type one or more custom identifying tags for this case. Press enter after each tag to begin a new one.', }); +export const TAGS_EMPTY_ERROR = i18n.translate('xpack.cases.createCase.fieldTagsEmptyError', { + defaultMessage: 'A tag must not be empty', +}); + export const NO_TAGS = i18n.translate('xpack.cases.caseView.noTags', { defaultMessage: 'No tags are currently assigned to this case.', }); diff --git a/x-pack/plugins/cases/public/components/create/schema.tsx b/x-pack/plugins/cases/public/components/create/schema.tsx index 41709a74d2fa5..57cf2f63a3fd2 100644 --- a/x-pack/plugins/cases/public/components/create/schema.tsx +++ b/x-pack/plugins/cases/public/components/create/schema.tsx @@ -6,7 +6,12 @@ */ import { CasePostRequest, ConnectorTypeFields, MAX_TITLE_LENGTH } from '../../../common'; -import { FIELD_TYPES, fieldValidators, FormSchema } from '../../common/shared_imports'; +import { + FIELD_TYPES, + fieldValidators, + FormSchema, + VALIDATION_TYPES, +} from '../../common/shared_imports'; import * as i18n from './translations'; import { OptionalFieldLabel } from './optional_field_label'; @@ -17,6 +22,13 @@ export const schemaTags = { label: i18n.TAGS, helpText: i18n.TAGS_HELP, labelAppend: OptionalFieldLabel, + validations: [ + { + validator: emptyField(i18n.TAGS_EMPTY_ERROR), + type: VALIDATION_TYPES.ARRAY_ITEM, + isBlocking: false, + }, + ], }; export type FormProps = Omit & {