diff options
author | kimsible <kimsible@users.noreply.github.com> | 2020-07-27 00:01:15 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-08-11 08:46:35 +0200 |
commit | 4abe9c593aab52391e4cb9e3a578ed46a479934d (patch) | |
tree | b42c819acc96612b1f0d926d8706660a9096a364 | |
parent | 62fc691548594bc96fd43e0c29dcd4191cb525f5 (diff) | |
download | PeerTube-4abe9c593aab52391e4cb9e3a578ed46a479934d.tar.gz PeerTube-4abe9c593aab52391e4cb9e3a578ed46a479934d.tar.zst PeerTube-4abe9c593aab52391e4cb9e3a578ed46a479934d.zip |
Add validator channel name
-rw-r--r-- | client/src/app/+admin/users/user-edit/user-create.component.ts | 2 | ||||
-rw-r--r-- | client/src/app/shared/shared-forms/form-validators/user-validators.service.ts | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-create.component.ts b/client/src/app/+admin/users/user-edit/user-create.component.ts index fc4013a04..3fddb9c09 100644 --- a/client/src/app/+admin/users/user-edit/user-create.component.ts +++ b/client/src/app/+admin/users/user-edit/user-create.component.ts | |||
@@ -44,7 +44,7 @@ export class UserCreateComponent extends UserEdit implements OnInit { | |||
44 | 44 | ||
45 | this.buildForm({ | 45 | this.buildForm({ |
46 | username: this.userValidatorsService.USER_USERNAME, | 46 | username: this.userValidatorsService.USER_USERNAME, |
47 | channelName: this.userValidatorsService.USER_USERNAME, | 47 | channelName: this.userValidatorsService.USER_CHANNEL_NAME, |
48 | email: this.userValidatorsService.USER_EMAIL, | 48 | email: this.userValidatorsService.USER_EMAIL, |
49 | password: this.isPasswordOptional() ? this.userValidatorsService.USER_PASSWORD_OPTIONAL : this.userValidatorsService.USER_PASSWORD, | 49 | password: this.isPasswordOptional() ? this.userValidatorsService.USER_PASSWORD_OPTIONAL : this.userValidatorsService.USER_PASSWORD, |
50 | role: this.userValidatorsService.USER_ROLE, | 50 | role: this.userValidatorsService.USER_ROLE, |
diff --git a/client/src/app/shared/shared-forms/form-validators/user-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/user-validators.service.ts index bd3030a54..61486bbab 100644 --- a/client/src/app/shared/shared-forms/form-validators/user-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/user-validators.service.ts | |||
@@ -6,6 +6,7 @@ import { Injectable } from '@angular/core' | |||
6 | @Injectable() | 6 | @Injectable() |
7 | export class UserValidatorsService { | 7 | export class UserValidatorsService { |
8 | readonly USER_USERNAME: BuildFormValidator | 8 | readonly USER_USERNAME: BuildFormValidator |
9 | readonly USER_CHANNEL_NAME: BuildFormValidator | ||
9 | readonly USER_EMAIL: BuildFormValidator | 10 | readonly USER_EMAIL: BuildFormValidator |
10 | readonly USER_PASSWORD: BuildFormValidator | 11 | readonly USER_PASSWORD: BuildFormValidator |
11 | readonly USER_PASSWORD_OPTIONAL: BuildFormValidator | 12 | readonly USER_PASSWORD_OPTIONAL: BuildFormValidator |
@@ -36,6 +37,21 @@ export class UserValidatorsService { | |||
36 | } | 37 | } |
37 | } | 38 | } |
38 | 39 | ||
40 | this.USER_CHANNEL_NAME = { | ||
41 | VALIDATORS: [ | ||
42 | Validators.required, | ||
43 | Validators.minLength(1), | ||
44 | Validators.maxLength(50), | ||
45 | Validators.pattern(/^[a-z0-9][a-z0-9._]*$/) | ||
46 | ], | ||
47 | MESSAGES: { | ||
48 | 'required': this.i18n('Channel name is required.'), | ||
49 | 'minlength': this.i18n('Channel name must be at least 1 character long.'), | ||
50 | 'maxlength': this.i18n('Channel name cannot be more than 50 characters long.'), | ||
51 | 'pattern': this.i18n('Channel name should be lowercase alphanumeric; dots and underscores are allowed.') | ||
52 | } | ||
53 | } | ||
54 | |||
39 | this.USER_EMAIL = { | 55 | this.USER_EMAIL = { |
40 | VALIDATORS: [ Validators.required, Validators.email ], | 56 | VALIDATORS: [ Validators.required, Validators.email ], |
41 | MESSAGES: { | 57 | MESSAGES: { |