mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit d7aacd723c
)
This commit is contained in:
parent
c2846881e5
commit
153c4b7fe0
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