Add validator channel name
This commit is contained in:
parent
62fc691548
commit
4abe9c593a
|
@ -44,7 +44,7 @@ export class UserCreateComponent extends UserEdit implements OnInit {
|
||||||
|
|
||||||
this.buildForm({
|
this.buildForm({
|
||||||
username: this.userValidatorsService.USER_USERNAME,
|
username: this.userValidatorsService.USER_USERNAME,
|
||||||
channelName: this.userValidatorsService.USER_USERNAME,
|
channelName: this.userValidatorsService.USER_CHANNEL_NAME,
|
||||||
email: this.userValidatorsService.USER_EMAIL,
|
email: this.userValidatorsService.USER_EMAIL,
|
||||||
password: this.isPasswordOptional() ? this.userValidatorsService.USER_PASSWORD_OPTIONAL : this.userValidatorsService.USER_PASSWORD,
|
password: this.isPasswordOptional() ? this.userValidatorsService.USER_PASSWORD_OPTIONAL : this.userValidatorsService.USER_PASSWORD,
|
||||||
role: this.userValidatorsService.USER_ROLE,
|
role: this.userValidatorsService.USER_ROLE,
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { Injectable } from '@angular/core'
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserValidatorsService {
|
export class UserValidatorsService {
|
||||||
readonly USER_USERNAME: BuildFormValidator
|
readonly USER_USERNAME: BuildFormValidator
|
||||||
|
readonly USER_CHANNEL_NAME: BuildFormValidator
|
||||||
readonly USER_EMAIL: BuildFormValidator
|
readonly USER_EMAIL: BuildFormValidator
|
||||||
readonly USER_PASSWORD: BuildFormValidator
|
readonly USER_PASSWORD: BuildFormValidator
|
||||||
readonly USER_PASSWORD_OPTIONAL: 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 = {
|
this.USER_EMAIL = {
|
||||||
VALIDATORS: [ Validators.required, Validators.email ],
|
VALIDATORS: [ Validators.required, Validators.email ],
|
||||||
MESSAGES: {
|
MESSAGES: {
|
||||||
|
|
Loading…
Reference in New Issue