diff --git a/x-pack/plugins/infra/public/pages/logs/settings/indices_configuration_form_state.ts b/x-pack/plugins/infra/public/pages/logs/settings/indices_configuration_form_state.ts
index d581c5feb3d6b..7165a34fb5ba1 100644
--- a/x-pack/plugins/infra/public/pages/logs/settings/indices_configuration_form_state.ts
+++ b/x-pack/plugins/infra/public/pages/logs/settings/indices_configuration_form_state.ts
@@ -19,6 +19,7 @@ import {
FormValidationError,
validateIndexPattern,
validateStringNotEmpty,
+ validateStringNoSpaces,
} from './validation_errors';
export type LogIndicesFormState = LogIndexNameReference | LogDataViewReference | undefined;
@@ -35,7 +36,10 @@ export const useLogIndicesFormElement = (initialValue: LogIndicesFormState) => {
if (logIndices == null) {
return validateStringNotEmpty('log data view', '');
} else if (logIndexNameReferenceRT.is(logIndices)) {
- return validateStringNotEmpty('log indices', logIndices.indexName);
+ return [
+ ...validateStringNotEmpty('log indices', logIndices.indexName),
+ ...validateStringNoSpaces('log indices', logIndices.indexName),
+ ];
} else {
const emptyStringErrors = validateStringNotEmpty('log data view', logIndices.dataViewId);
diff --git a/x-pack/plugins/infra/public/pages/logs/settings/source_configuration_form_errors.tsx b/x-pack/plugins/infra/public/pages/logs/settings/source_configuration_form_errors.tsx
index c6a185aeda7ca..e7cdf43136f3f 100644
--- a/x-pack/plugins/infra/public/pages/logs/settings/source_configuration_form_errors.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/settings/source_configuration_form_errors.tsx
@@ -40,6 +40,16 @@ export const LogSourceConfigurationFormError: React.FC<{ error: FormValidationEr
}}
/>
);
+ } else if (error.type === 'includes_spaces') {
+ return (
+
+ );
} else if (error.type === 'empty_column_list') {
return (
value === '' ? [{ type: 'empty_field', fieldName }] : [];
+export const validateStringNoSpaces = (fieldName: string, value: string): FormValidationError[] =>
+ value.includes(' ') ? [{ type: 'includes_spaces', fieldName }] : [];
+
export const validateColumnListNotEmpty = (columns: unknown[]): FormValidationError[] =>
columns.length <= 0 ? [{ type: 'empty_column_list' }] : [];