mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Cases] Fix form case tags displaying error when all tags are removed (#123172)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
cb3e0ec67a
commit
d7aacd723c
1 changed files with 12 additions and 1 deletions
|
@ -18,6 +18,8 @@ import * as i18n from './translations';
|
|||
import { OptionalFieldLabel } from './optional_field_label';
|
||||
const { emptyField, maxLengthField } = fieldValidators;
|
||||
|
||||
const isEmptyString = (value: string) => value.trim() === '';
|
||||
|
||||
export const schemaTags = {
|
||||
type: FIELD_TYPES.COMBO_BOX,
|
||||
label: i18n.TAGS,
|
||||
|
@ -25,7 +27,16 @@ export const schemaTags = {
|
|||
labelAppend: OptionalFieldLabel,
|
||||
validations: [
|
||||
{
|
||||
validator: emptyField(i18n.TAGS_EMPTY_ERROR),
|
||||
validator: ({ value }: { value: string | string[] }) => {
|
||||
if (
|
||||
(!Array.isArray(value) && isEmptyString(value)) ||
|
||||
(Array.isArray(value) && value.length > 0 && value.find(isEmptyString))
|
||||
) {
|
||||
return {
|
||||
message: i18n.TAGS_EMPTY_ERROR,
|
||||
};
|
||||
}
|
||||
},
|
||||
type: VALIDATION_TYPES.ARRAY_ITEM,
|
||||
isBlocking: false,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue