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

editor: add email validator #499

Merged
merged 1 commit into from
Jun 10, 2022
Merged

Conversation

Garfield-fr
Copy link
Contributor

Co-Authored-by: Bertrand Zuchuat bertrand.zuchuat@rero.ch

Why are you opening this PR?

  • Which task/US does it implement?
  • Which issue does it fix?

How to test?

  • What command should I have to run to test your PR?
  • What should I test through the UI?

Code review check list

  • Commit message template compliance.
  • Commit message without typos.
  • File names.
  • Functions names.
  • Functions docstrings.
  • Unnecessary commited files?
  • Extracted translations?

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
@zannkukai zannkukai force-pushed the zub-email-validator branch from 7a79afe to 765a325 Compare May 31, 2022 08:03
field.validators.email = {
expression: (control: AbstractControl) => !control.value
? true : (new RegExp(emailPattern)).test(control.value),
message: `This value is not a valid email.`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Translation seems missing.


export function emailValidator(field: FormlyFieldConfig) {
// Regex pattern to check email
const emailPattern = /^([A-Za-z0-9\._%+-]+@[A-Za-z0-9\.-]+\.[A-Z|a-z]{2,})$/;
Copy link
Contributor

Choose a reason for hiding this comment

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

A comment to explain what is supported and what is not would be great.

import { AbstractControl } from '@angular/forms';
import { FormlyFieldConfig } from '@ngx-formly/core';

export function emailValidator(field: FormlyFieldConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It can be a good idea to write some tests.

@zannkukai zannkukai merged commit 0e0b808 into rero:staging Jun 10, 2022
@Garfield-fr Garfield-fr deleted the zub-email-validator branch September 12, 2022 13:03
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

Successfully merging this pull request may close these issues.

4 participants