From b9fc2f4b464f81c286f2e8ab9905625a8b8797fd Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Mon, 4 Dec 2023 20:08:58 +0100 Subject: [PATCH] Fix inconsistent error message --- src/components/Form/FormProvider.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Form/FormProvider.js b/src/components/Form/FormProvider.js index 42d0d2bf9d81..847750f78bf5 100644 --- a/src/components/Form/FormProvider.js +++ b/src/components/Form/FormProvider.js @@ -125,7 +125,7 @@ function FormProvider({validate, formID, shouldValidateOnBlur, shouldValidateOnC } FormActions.setErrorFields(formID, null); - const validateErrors = validate(values) || {}; + const validateErrors = validate(trimmedStringValues) || {}; // Validate the input for html tags. It should supercede any other error _.each(trimmedStringValues, (inputValue, inputID) => { @@ -154,6 +154,11 @@ function FormProvider({validate, formID, shouldValidateOnBlur, shouldValidateOnC } } } + + if (isMatch && leadingSpaceIndex === -1) { + return; + } + // Add a validation error here because it is a string value that contains HTML characters validateErrors[inputID] = 'common.error.invalidCharacter'; });