mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #1984 from tdonohue/fix_1983
Fix email validation regex to use email validation regex from HTML5 specs
This commit is contained in:
@@ -95,6 +95,10 @@ describe('RegisterEmailComponent', () => {
|
|||||||
comp.form.patchValue({email: 'valid@email.org'});
|
comp.form.patchValue({email: 'valid@email.org'});
|
||||||
expect(comp.form.invalid).toBeFalse();
|
expect(comp.form.invalid).toBeFalse();
|
||||||
});
|
});
|
||||||
|
it('should be valid when uppercase letters are used', () => {
|
||||||
|
comp.form.patchValue({email: 'VALID@email.org'});
|
||||||
|
expect(comp.form.invalid).toBeFalse();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('register', () => {
|
describe('register', () => {
|
||||||
it('should send a registration to the service and on success display a message and return to home', () => {
|
it('should send a registration to the service and on success display a message and return to home', () => {
|
||||||
|
@@ -79,7 +79,9 @@ export class RegisterEmailFormComponent implements OnInit {
|
|||||||
this.form = this.formBuilder.group({
|
this.form = this.formBuilder.group({
|
||||||
email: new FormControl('', {
|
email: new FormControl('', {
|
||||||
validators: [Validators.required,
|
validators: [Validators.required,
|
||||||
Validators.pattern('^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$')
|
// Regex pattern borrowed from HTML5 specs for a valid email address:
|
||||||
|
// https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
|
||||||
|
Validators.pattern('^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$')
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user