diff options
Diffstat (limited to 'client/src/app/shared/forms/form-validators/user-validators.service.ts')
-rw-r--r-- | client/src/app/shared/forms/form-validators/user-validators.service.ts | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/client/src/app/shared/forms/form-validators/user-validators.service.ts b/client/src/app/shared/forms/form-validators/user-validators.service.ts index 6589b2580..2dafb1816 100644 --- a/client/src/app/shared/forms/form-validators/user-validators.service.ts +++ b/client/src/app/shared/forms/form-validators/user-validators.service.ts | |||
@@ -12,7 +12,7 @@ export class UserValidatorsService { | |||
12 | readonly USER_VIDEO_QUOTA: BuildFormValidator | 12 | readonly USER_VIDEO_QUOTA: BuildFormValidator |
13 | readonly USER_VIDEO_QUOTA_DAILY: BuildFormValidator | 13 | readonly USER_VIDEO_QUOTA_DAILY: BuildFormValidator |
14 | readonly USER_ROLE: BuildFormValidator | 14 | readonly USER_ROLE: BuildFormValidator |
15 | readonly USER_DISPLAY_NAME: BuildFormValidator | 15 | readonly USER_DISPLAY_NAME_REQUIRED: BuildFormValidator |
16 | readonly USER_DESCRIPTION: BuildFormValidator | 16 | readonly USER_DESCRIPTION: BuildFormValidator |
17 | readonly USER_TERMS: BuildFormValidator | 17 | readonly USER_TERMS: BuildFormValidator |
18 | 18 | ||
@@ -85,18 +85,7 @@ export class UserValidatorsService { | |||
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | this.USER_DISPLAY_NAME = { | 88 | this.USER_DISPLAY_NAME_REQUIRED = this.getDisplayName(true) |
89 | VALIDATORS: [ | ||
90 | Validators.required, | ||
91 | Validators.minLength(1), | ||
92 | Validators.maxLength(50) | ||
93 | ], | ||
94 | MESSAGES: { | ||
95 | 'required': this.i18n('Display name is required.'), | ||
96 | 'minlength': this.i18n('Display name must be at least 1 character long.'), | ||
97 | 'maxlength': this.i18n('Display name cannot be more than 50 characters long.') | ||
98 | } | ||
99 | } | ||
100 | 89 | ||
101 | this.USER_DESCRIPTION = { | 90 | this.USER_DESCRIPTION = { |
102 | VALIDATORS: [ | 91 | VALIDATORS: [ |
@@ -129,4 +118,22 @@ export class UserValidatorsService { | |||
129 | } | 118 | } |
130 | } | 119 | } |
131 | } | 120 | } |
121 | |||
122 | private getDisplayName (required: boolean) { | ||
123 | const control = { | ||
124 | VALIDATORS: [ | ||
125 | Validators.minLength(1), | ||
126 | Validators.maxLength(120) | ||
127 | ], | ||
128 | MESSAGES: { | ||
129 | 'required': this.i18n('Display name is required.'), | ||
130 | 'minlength': this.i18n('Display name must be at least 1 character long.'), | ||
131 | 'maxlength': this.i18n('Display name cannot be more than 50 characters long.') | ||
132 | } | ||
133 | } | ||
134 | |||
135 | if (required) control.VALIDATORS.push(Validators.required) | ||
136 | |||
137 | return control | ||
138 | } | ||
132 | } | 139 | } |