diff --git a/src/hooks/queries/useCustomValidationConfig.ts b/src/hooks/queries/useCustomValidationConfig.ts index 237e67fa04..e9276b5fbd 100644 --- a/src/hooks/queries/useCustomValidationConfig.ts +++ b/src/hooks/queries/useCustomValidationConfig.ts @@ -33,14 +33,18 @@ export const useCustomValidationConfig = (): UseQueryResult fetchCustomValidationConfig(dataTypeId), { enabled: Boolean(dataTypeId?.length), onSuccess: (customValidationConfig) => { - if (!customValidationConfig) { - return; + if (customValidationConfig) { + const validationDefinition = resolveExpressionValidationConfig(customValidationConfig); + dispatch(CustomValidationActions.fetchCustomValidationsFulfilled(validationDefinition)); + } else { + dispatch(CustomValidationActions.fetchCustomValidationsFulfilled(null)); } - const validationDefinition = resolveExpressionValidationConfig(customValidationConfig); - dispatch(CustomValidationActions.fetchCustomValidationsFulfilled(validationDefinition)); }, onError: (error: AxiosError) => { - if (error.response?.status !== 404) { + if (error.response?.status === 404) { + dispatch(CustomValidationActions.fetchCustomValidationsRejected(null)); + window.logWarn('App does not support custom validation using expressions'); + } else { dispatch(CustomValidationActions.fetchCustomValidationsRejected(error)); window.logError('Fetching validation configuration failed:\n', error); }