X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fform-validators%2Fuser-validators.ts;h=976c97b872f981c6d71a0f010be66000e5a5e06f;hb=8cbc40b2fe9d36ef0505b9441276ca561342e9e9;hp=18199505c367b70a912da2cc91fc04362bd43215;hpb=7ed1edbbe4ffbef28093e4f5630751cb652814e4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/form-validators/user-validators.ts b/client/src/app/shared/form-validators/user-validators.ts index 18199505c..976c97b87 100644 --- a/client/src/app/shared/form-validators/user-validators.ts +++ b/client/src/app/shared/form-validators/user-validators.ts @@ -1,12 +1,14 @@ import { Validators } from '@angular/forms' import { BuildFormValidator } from './form-validator.model' +export const USER_USERNAME_REGEX_CHARACTERS = '[a-z0-9][a-z0-9._]' + export const USER_USERNAME_VALIDATOR: BuildFormValidator = { VALIDATORS: [ Validators.required, Validators.minLength(1), Validators.maxLength(50), - Validators.pattern(/^[a-z0-9][a-z0-9._]*$/) + Validators.pattern(new RegExp(`^${USER_USERNAME_REGEX_CHARACTERS}*$`)) ], MESSAGES: { 'required': $localize`Username is required.`, @@ -27,7 +29,7 @@ export const USER_CHANNEL_NAME_VALIDATOR: BuildFormValidator = { 'required': $localize`Channel name is required.`, 'minlength': $localize`Channel name must be at least 1 character long.`, 'maxlength': $localize`Channel name cannot be more than 50 characters long.`, - 'pattern': $localize`Channel name should be lowercase alphanumeric; dots and underscores are allowed.` + 'pattern': $localize`Channel name should be lowercase, and can contain only alphanumeric characters, dots and underscores.` } } @@ -39,6 +41,26 @@ export const USER_EMAIL_VALIDATOR: BuildFormValidator = { } } +export const USER_HANDLE_VALIDATOR: BuildFormValidator = { + VALIDATORS: [ + Validators.required, + Validators.pattern(/@.+/) + ], + MESSAGES: { + 'required': $localize`Handle is required.`, + 'pattern': $localize`Handle must be valid (eg. chocobozzz@example.com).` + } +} + +export const USER_EXISTING_PASSWORD_VALIDATOR: BuildFormValidator = { + VALIDATORS: [ + Validators.required + ], + MESSAGES: { + 'required': $localize`Password is required.` + } +} + export const USER_PASSWORD_VALIDATOR: BuildFormValidator = { VALIDATORS: [ Validators.required, @@ -106,9 +128,7 @@ export const USER_DESCRIPTION_VALIDATOR: BuildFormValidator = { } export const USER_TERMS_VALIDATOR: BuildFormValidator = { - VALIDATORS: [ - Validators.requiredTrue - ], + VALIDATORS: [ Validators.requiredTrue ], MESSAGES: { 'required': $localize`You must agree with the instance terms in order to register on it.` }