Skip to content

Fix #2499 - typo in error "please enter a email" #2597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 13, 2023

Conversation

lindapaiste
Copy link
Collaborator

@lindapaiste lindapaiste commented Nov 12, 2023

Fixes #2499

Changes:

  • Delete the untranslated form error "Please enter a ____" in components AccountForm and SignupForm.

Explanation:

The primary validation of this form comes from a form-level validation function. This function already checks for empty email and password and returns translated error messages.

if (!formProps.email) {
errors.email = i18n.t('ReduxFormUtils.errorEmptyEmail');
} else if (

Additionally, we have a field-level validation function which calls the '/signup/duplicate_check' API endpoint.
function asyncValidate(fieldToValidate, value) {
if (!value || value.trim().length === 0)
return `Please enter a ${fieldToValidate}.`;
const queryParams = {};
queryParams[fieldToValidate] = value;
queryParams.check_type = fieldToValidate;
return apiClient
.get('/signup/duplicate_check', { params: queryParams })
.then((response) => {
if (response.data.exists) {
return response.data.message;
}
return '';
});
}
function validateUsername(username) {
return asyncValidate('username', username);
}
function validateEmail(email) {
return asyncValidate('email', email);
}

We don't need to call the duplicate check API if the field is empty. So we check for this and return early. But the message that we are returning there is not translated and not semantically correct ("a email" instead of "an email").

We can instead return an empty string '' (or just return; but eslint prefers the consistent string return value). Returning a falsey value instead of an error message means that this check passes and does not set an error, but that's okay because it is caught later on by the form-level validation function, validateSignup or validateSettings, where it is handled properly.

Future Tasks:

  • duplicateCheck function is the same in both files.
  • Message "This email is already taken." comes from the server and is not translated.
  • We call the API more than is necessary because we re-query when other fields change (not just the field being checked). This is the standard behavior of the form package but there are some workarounds. See validateFields={[]} runs validation when other fields change final-form/react-final-form#170
  • We my want to throttle the API calls instead of calling on every keystroke.
  • We should delay the duplicate email check until the email passes the "invalid email" regex check. We don't need to check while they are typing "linda..." because we wouldn't accept that email anyways. We only need to check after they have typed the "@gmail.com" part.

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123

@lindapaiste lindapaiste added the Area: Translation For localization of the p5.js editor or contributor documentation label Nov 12, 2023
@raclim raclim added this to the PATCH Release for 2.9.3 milestone Nov 13, 2023
Copy link
Collaborator

@raclim raclim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me so far, thanks for the context and for pointing out some other issues around it! Maybe we'd also want them in a separate issue at some point 😄

@raclim raclim merged commit 411ff89 into processing:develop Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Translation For localization of the p5.js editor or contributor documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Translation Typos in Sign Up Form Text
2 participants