[Index Management] Restrict dot-prefixed index patterns in template form (#193196)

Closes https://github.com/elastic/kibana/issues/190251

## Summary

This PR adds validation that restricts creating a template with a
dot-prefixed index pattern.

<img width="1194" alt="Screenshot 2024-09-18 at 10 49 47"
src="https://github.com/user-attachments/assets/f24c3e29-7db0-46fc-97de-52d4654073de">

Note: I tried adding tests for this validation
[here](6a3adf73da/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_create.test.tsx (L163)),
but it didn't work because the index pattern field is mocked in the
tests and errors are not triggered from invalid values.
This commit is contained in:
Elena Stoeva 2024-09-18 16:45:59 +01:00 committed by GitHub
parent 78b21cd9f9
commit 38d6143f72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -129,6 +129,18 @@ export const schemas: Record<string, FormSchema> = {
type: VALIDATION_TYPES.ARRAY_ITEM,
isBlocking: false,
},
{
validator: startsWithField({
char: '.',
message: i18n.translate(
'xpack.idxMgmt.templateValidation.indexPatternDotPrefixedError',
{
defaultMessage: 'Index patterns cannot match dot-prefixed indices.',
}
),
}),
type: VALIDATION_TYPES.ARRAY_ITEM,
},
],
},
doCreateDataStream: {