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

Add empty tag validation to cases #108699

Merged
merged 1 commit into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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