aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-02-18 09:29:59 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-02-18 09:29:59 +0100
commitad4a8a1cca1049f600ebcdce9260c1021cd821a5 (patch)
treeca8ffba899b024d56d1bd7846f61aecae0821c82 /client/src/app/shared
parent5d67f289df4a68e35ad7e0af3c601c7db0dc7586 (diff)
downloadPeerTube-ad4a8a1cca1049f600ebcdce9260c1021cd821a5.tar.gz
PeerTube-ad4a8a1cca1049f600ebcdce9260c1021cd821a5.tar.zst
PeerTube-ad4a8a1cca1049f600ebcdce9260c1021cd821a5.zip
Add email to users
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/forms/form-validators/email.validator.ts13
-rw-r--r--client/src/app/shared/forms/form-validators/host.validator.ts2
-rw-r--r--client/src/app/shared/forms/form-validators/index.ts1
-rw-r--r--client/src/app/shared/forms/form-validators/user.ts9
4 files changed, 24 insertions, 1 deletions
diff --git a/client/src/app/shared/forms/form-validators/email.validator.ts b/client/src/app/shared/forms/form-validators/email.validator.ts
new file mode 100644
index 000000000..6a2c3bdca
--- /dev/null
+++ b/client/src/app/shared/forms/form-validators/email.validator.ts
@@ -0,0 +1,13 @@
1import { FormControl } from '@angular/forms';
2
3export function validateEmail(c: FormControl) {
4 // Thanks to http://emailregex.com/
5 /* tslint:disable */
6 const EMAIL_REGEXP = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
7
8 return EMAIL_REGEXP.test(c.value) ? null : {
9 email: {
10 valid: false
11 }
12 };
13}
diff --git a/client/src/app/shared/forms/form-validators/host.validator.ts b/client/src/app/shared/forms/form-validators/host.validator.ts
index ea3e43cb1..ec417e079 100644
--- a/client/src/app/shared/forms/form-validators/host.validator.ts
+++ b/client/src/app/shared/forms/form-validators/host.validator.ts
@@ -2,7 +2,7 @@ import { FormControl } from '@angular/forms';
2 2
3export function validateHost(c: FormControl) { 3export function validateHost(c: FormControl) {
4 // Thanks to http://stackoverflow.com/a/106223 4 // Thanks to http://stackoverflow.com/a/106223
5 let HOST_REGEXP = new RegExp( 5 const HOST_REGEXP = new RegExp(
6 '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$' 6 '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$'
7 ); 7 );
8 8
diff --git a/client/src/app/shared/forms/form-validators/index.ts b/client/src/app/shared/forms/form-validators/index.ts
index ab7c2df31..669411a54 100644
--- a/client/src/app/shared/forms/form-validators/index.ts
+++ b/client/src/app/shared/forms/form-validators/index.ts
@@ -1,3 +1,4 @@
1export * from './email.validator';
1export * from './host.validator'; 2export * from './host.validator';
2export * from './user'; 3export * from './user';
3export * from './video-abuse'; 4export * from './video-abuse';
diff --git a/client/src/app/shared/forms/form-validators/user.ts b/client/src/app/shared/forms/form-validators/user.ts
index 5b11ff265..0ad0e2a4b 100644
--- a/client/src/app/shared/forms/form-validators/user.ts
+++ b/client/src/app/shared/forms/form-validators/user.ts
@@ -1,5 +1,7 @@
1import { Validators } from '@angular/forms'; 1import { Validators } from '@angular/forms';
2 2
3import { validateEmail } from './email.validator';
4
3export const USER_USERNAME = { 5export const USER_USERNAME = {
4 VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(20) ], 6 VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(20) ],
5 MESSAGES: { 7 MESSAGES: {
@@ -8,6 +10,13 @@ export const USER_USERNAME = {
8 'maxlength': 'Username cannot be more than 20 characters long.' 10 'maxlength': 'Username cannot be more than 20 characters long.'
9 } 11 }
10}; 12};
13export const USER_EMAIL = {
14 VALIDATORS: [ Validators.required, validateEmail ],
15 MESSAGES: {
16 'required': 'Email is required.',
17 'email': 'Email must be valid.',
18 }
19};
11export const USER_PASSWORD = { 20export const USER_PASSWORD = {
12 VALIDATORS: [ Validators.required, Validators.minLength(6) ], 21 VALIDATORS: [ Validators.required, Validators.minLength(6) ],
13 MESSAGES: { 22 MESSAGES: {