Skip to content

Commit

Permalink
Fix inconsistent error message
Browse files Browse the repository at this point in the history
  • Loading branch information
kowczarz committed Dec 4, 2023
1 parent 9fa1591 commit b9fc2f4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/Form/FormProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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';
});
Expand Down

0 comments on commit b9fc2f4

Please sign in to comment.