]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/form-validators/video-ownership-change-validators.ts
Merge branch 'develop' into shorter-URLs-channels-accounts
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / form-validators / video-ownership-change-validators.ts
CommitLineData
7ed1edbb
C
1import { AbstractControl, ValidationErrors, Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3
4export const OWNERSHIP_CHANGE_CHANNEL_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [ Validators.required ],
6 MESSAGES: {
7 'required': $localize`The channel is required.`
8 }
9}
10
11export const OWNERSHIP_CHANGE_USERNAME_VALIDATOR: BuildFormValidator = {
12 VALIDATORS: [ Validators.required, localAccountValidator ],
13 MESSAGES: {
14 'required': $localize`The username is required.`,
15 'localAccountOnly': $localize`You can only transfer ownership to a local account`
16 }
17}
18
19function localAccountValidator (control: AbstractControl): ValidationErrors {
20 if (control.value.includes('@')) {
21 return { 'localAccountOnly': true }
22 }
23
24 return null
25}