Skip to content
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

(3) Email Regex is missing in Person new and Person edit #497

Closed
njaeggi opened this issue Feb 20, 2023 · 5 comments
Closed

(3) Email Regex is missing in Person new and Person edit #497

njaeggi opened this issue Feb 20, 2023 · 5 comments
Assignees

Comments

@njaeggi
Copy link
Contributor

njaeggi commented Feb 20, 2023

Currently it's possible to put any text in the email field when creating or editing a person, add a simple email regex to prevent this from happening

@Robin481 Robin481 changed the title Email Regex is missing in Person new and Person edit (2) Email Regex is missing in Person new and Person edit Feb 20, 2023
@lkleisa lkleisa self-assigned this Feb 22, 2023
@lkleisa
Copy link
Collaborator

lkleisa commented Feb 22, 2023

Draft PR: #501

@lkleisa
Copy link
Collaborator

lkleisa commented Feb 22, 2023

I added email regex in validation file frontend/app/validations/person-form.js and also in backend in person.rb. Now, you have on edit a red cross when email is empty or a red text when the format is not correct. On create, you receive a red toastr message, when email is empty or when format is not correct.

We have the following problems:

  1. In frontend, we need to pass the translated version of the message Gib eine gültige Email Adresse ein some way. It should be possible to pass a custom validation message, but I could not make it.
  2. The form validation of the person new is in backend and not like the person edit in frontend. Because of that, we can not use the same validation file frontend/app/validations/person-form.js. It would make sense to move the backend validation to the frontend (if we have the time for that).
  3. If you edit a person, remove the email field, click submit, there are multiple errors, from backend and also from frontend. If you click again submit, nothing is happening. No error, no request, no console output.

Good doc: https://github.com/poteto/ember-changeset-validations

@lkleisa
Copy link
Collaborator

lkleisa commented Feb 22, 2023

Todo:

  • Use translation for error message
  • Define, if we use backend or frontend or both for validations
  • Fix bug with second click on submit button
  • Backend tests
  • Fronend tests
  • Smoke test

@Robin481 Robin481 changed the title (2) Email Regex is missing in Person new and Person edit (3) Email Regex is missing in Person new and Person edit Feb 27, 2023
@lkleisa
Copy link
Collaborator

lkleisa commented Feb 27, 2023

Frontend test for edit person is done, now 2 for create person are needed....

@lkleisa
Copy link
Collaborator

lkleisa commented Mar 1, 2023

The problem with the frontend test is the following:
In person new, the whole person object is sent to the backend. There happens the validation. The rails return the error and in ember, we display it with an alert. In person edit, the validation happens in frontend. We can easily test, if there is a validation error or not. In person new, it's a little bit more difficult.
When we use a debugger and the developer mode in the test, we see when we click on the submit button, that for some ms the alerts are displayed. Also, when we use a debugger before the error rendering, we have the 2 errors from the backend in right form (1: email muss ausgefüllt sein, 2: email format nicht gültig).
@mtnstar will look about it tomorrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants