Skip to content

Commit

Permalink
Add empty tag validation to cases (#108699)
Browse files Browse the repository at this point in the history
  • Loading branch information
machadoum authored and kibanamachine committed Aug 16, 2021
1 parent a6dabbc commit e7e3f80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions x-pack/plugins/cases/public/common/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
});
Expand Down
14 changes: 13 additions & 1 deletion x-pack/plugins/cases/public/components/create/schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<CasePostRequest, 'connector' | 'settings' | 'owner'> & {
Expand Down

0 comments on commit e7e3f80

Please sign in to comment.