@@ -12,6 +12,7 @@ import {
1212 FormSchema ,
1313 FIELD_TYPES ,
1414 VALIDATION_TYPES ,
15+ FieldConfig ,
1516} from '../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib' ;
1617
1718import {
@@ -34,70 +35,71 @@ const {
3435const { toInt } = fieldFormatters ;
3536const indexPatternInvalidCharacters = INVALID_INDEX_PATTERN_CHARS . join ( ' ' ) ;
3637
37- export const schemas : Record < string , FormSchema > = {
38- logistics : {
39- name : {
40- type : FIELD_TYPES . TEXT ,
41- label : i18n . translate ( 'xpack.idxMgmt.templateForm.stepLogistics.fieldNameLabel' , {
42- defaultMessage : 'Name' ,
38+ export const nameConfig : FieldConfig = {
39+ type : FIELD_TYPES . TEXT ,
40+ label : i18n . translate ( 'xpack.idxMgmt.templateForm.stepLogistics.fieldNameLabel' , {
41+ defaultMessage : 'Name' ,
42+ } ) ,
43+ validations : [
44+ {
45+ validator : emptyField (
46+ i18n . translate ( 'xpack.idxMgmt.templateValidation.templateNameRequiredError' , {
47+ defaultMessage : 'A template name is required.' ,
48+ } )
49+ ) ,
50+ } ,
51+ {
52+ validator : containsCharsField ( {
53+ chars : ' ' ,
54+ message : i18n . translate ( 'xpack.idxMgmt.templateValidation.templateNameSpacesError' , {
55+ defaultMessage : 'Spaces are not allowed in a template name.' ,
56+ } ) ,
4357 } ) ,
44- validations : [
45- {
46- validator : emptyField (
47- i18n . translate ( 'xpack.idxMgmt.templateValidation.templateNameRequiredError' , {
48- defaultMessage : 'A template name is required.' ,
49- } )
50- ) ,
51- } ,
52- {
53- validator : containsCharsField ( {
54- chars : ' ' ,
55- message : i18n . translate ( 'xpack.idxMgmt.templateValidation.templateNameSpacesError' , {
56- defaultMessage : 'Spaces are not allowed in a template name.' ,
57- } ) ,
58- } ) ,
59- } ,
60- {
61- validator : startsWithField ( {
62- char : '_' ,
63- message : i18n . translate (
64- 'xpack.idxMgmt.templateValidation.templateNameUnderscoreError' ,
65- {
66- defaultMessage : 'A template name must not start with an underscore.' ,
67- }
68- ) ,
69- } ) ,
70- } ,
71- {
72- validator : startsWithField ( {
73- char : '.' ,
74- message : i18n . translate ( 'xpack.idxMgmt.templateValidation.templateNamePeriodError' , {
75- defaultMessage : 'A template name must not start with a period.' ,
76- } ) ,
77- } ) ,
78- } ,
79- {
80- validator : containsCharsField ( {
81- chars : INVALID_TEMPLATE_NAME_CHARS ,
82- message : ( { charsFound } ) =>
83- i18n . translate (
84- 'xpack.idxMgmt.templateValidation.templateNameInvalidaCharacterError' ,
85- {
86- defaultMessage : 'A template name must not contain the character "{invalidChar}"' ,
87- values : { invalidChar : charsFound [ 0 ] } ,
88- }
89- ) ,
58+ } ,
59+ {
60+ validator : startsWithField ( {
61+ char : '_' ,
62+ message : i18n . translate ( 'xpack.idxMgmt.templateValidation.templateNameUnderscoreError' , {
63+ defaultMessage : 'A template name must not start with an underscore.' ,
64+ } ) ,
65+ } ) ,
66+ } ,
67+ {
68+ validator : startsWithField ( {
69+ char : '.' ,
70+ message : i18n . translate ( 'xpack.idxMgmt.templateValidation.templateNamePeriodError' , {
71+ defaultMessage : 'A template name must not start with a period.' ,
72+ } ) ,
73+ } ) ,
74+ } ,
75+ {
76+ validator : containsCharsField ( {
77+ chars : INVALID_TEMPLATE_NAME_CHARS ,
78+ message : ( { charsFound } ) =>
79+ i18n . translate ( 'xpack.idxMgmt.templateValidation.templateNameInvalidaCharacterError' , {
80+ defaultMessage : 'A template name must not contain the character "{invalidChar}"' ,
81+ values : { invalidChar : charsFound [ 0 ] } ,
9082 } ) ,
91- } ,
92- {
93- validator : lowerCaseStringField (
94- i18n . translate ( 'xpack.idxMgmt.templateValidation.templateNameLowerCaseRequiredError' , {
95- defaultMessage : 'The template name must be in lowercase.' ,
96- } )
97- ) ,
98- } ,
99- ] ,
83+ } ) ,
10084 } ,
85+ {
86+ validator : lowerCaseStringField (
87+ i18n . translate ( 'xpack.idxMgmt.templateValidation.templateNameLowerCaseRequiredError' , {
88+ defaultMessage : 'The template name must be in lowercase.' ,
89+ } )
90+ ) ,
91+ } ,
92+ ] ,
93+ } ;
94+
95+ export const nameConfigWithoutValidations : FieldConfig = {
96+ ...nameConfig ,
97+ validations : [ ] ,
98+ } ;
99+
100+ export const schemas : Record < string , FormSchema > = {
101+ logistics : {
102+ name : nameConfig ,
101103 indexPatterns : {
102104 type : FIELD_TYPES . COMBO_BOX ,
103105 defaultValue : [ ] ,
0 commit comments