diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/advanced_step/advanced_step_form.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/advanced_step/advanced_step_form.tsx index 7409e414af2b6..1aad5dfd9cfb9 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/advanced_step/advanced_step_form.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/advanced_step/advanced_step_form.tsx @@ -78,7 +78,10 @@ export const AdvancedStepForm: FC = ({ const isRegOrClassJob = jobType === ANALYSIS_CONFIG_TYPE.REGRESSION || jobType === ANALYSIS_CONFIG_TYPE.CLASSIFICATION; - const mmlInvalid = modelMemoryLimitValidationResult !== null; + const mmlInvalid = + modelMemoryLimitValidationResult !== null && + (modelMemoryLimitValidationResult.invalidUnits !== undefined || + modelMemoryLimitValidationResult.required === true); const isStepInvalid = mmlInvalid || @@ -340,7 +343,7 @@ export const AdvancedStepForm: FC = ({ label={i18n.translate('xpack.ml.dataframe.analytics.create.modelMemoryLimitLabel', { defaultMessage: 'Model memory limit', })} - isInvalid={mmlInvalid} + isInvalid={modelMemoryLimitValidationResult !== null} error={mmlErrors} helpText={i18n.translate( 'xpack.ml.dataframe.analytics.create.modelMemoryLimitHelpText', @@ -359,7 +362,7 @@ export const AdvancedStepForm: FC = ({ disabled={isJobCreated} value={modelMemoryLimit || ''} onChange={(e) => setFormState({ modelMemoryLimit: e.target.value })} - isInvalid={mmlInvalid} + isInvalid={modelMemoryLimitValidationResult !== null} data-test-subj="mlAnalyticsCreateJobWizardModelMemoryInput" /> diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts index 59c6f7249408d..6fb3904e76ecb 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts @@ -72,7 +72,7 @@ export function getModelMemoryLimitErrors(mmlValidationResult: any): string[] | if (errorKey === 'min') { acc.push( i18n.translate('xpack.ml.dataframe.analytics.create.modelMemoryUnitsMinError', { - defaultMessage: 'Model memory limit cannot be lower than {mml}', + defaultMessage: 'Model memory limit is lower than estimated value {mml}', values: { mml: mmlValidationResult.min.minValue, }, @@ -425,12 +425,15 @@ const validateForm = (state: State): State => { dependentVariable === ''; const mmlValidationResult = validateMml(estimatedModelMemoryLimit, modelMemoryLimit); + const mmlInvalid = + mmlValidationResult !== null && + (mmlValidationResult.invalidUnits !== undefined || mmlValidationResult.required === true); state.form.modelMemoryLimitValidationResult = mmlValidationResult; state.isValid = !jobTypeEmpty && - !mmlValidationResult && + !mmlInvalid && !jobIdEmpty && jobIdValid && !jobIdExists &&