From 4abe9c593aab52391e4cb9e3a578ed46a479934d Mon Sep 17 00:00:00 2001 From: kimsible Date: Mon, 27 Jul 2020 00:01:15 +0200 Subject: Add validator channel name --- .../form-validators/user-validators.service.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'client/src/app/shared') 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' @Injectable() export class UserValidatorsService { readonly USER_USERNAME: BuildFormValidator + readonly USER_CHANNEL_NAME: BuildFormValidator readonly USER_EMAIL: BuildFormValidator readonly USER_PASSWORD: BuildFormValidator readonly USER_PASSWORD_OPTIONAL: BuildFormValidator @@ -36,6 +37,21 @@ export class UserValidatorsService { } } + this.USER_CHANNEL_NAME = { + VALIDATORS: [ + Validators.required, + Validators.minLength(1), + Validators.maxLength(50), + Validators.pattern(/^[a-z0-9][a-z0-9._]*$/) + ], + MESSAGES: { + 'required': this.i18n('Channel name is required.'), + 'minlength': this.i18n('Channel name must be at least 1 character long.'), + 'maxlength': this.i18n('Channel name cannot be more than 50 characters long.'), + 'pattern': this.i18n('Channel name should be lowercase alphanumeric; dots and underscores are allowed.') + } + } + this.USER_EMAIL = { VALIDATORS: [ Validators.required, Validators.email ], MESSAGES: { -- cgit v1.2.3