]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-forms/form-validators/video-change-ownership-validators.service.ts
Migrate to $localize
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-forms / form-validators / video-change-ownership-validators.service.ts
CommitLineData
74d63469 1import { Injectable } from '@angular/core'
66357162 2import { AbstractControl, ValidationErrors, Validators } from '@angular/forms'
67ed6552 3import { BuildFormValidator } from './form-validator.service'
74d63469
GR
4
5@Injectable()
6export class VideoChangeOwnershipValidatorsService {
7 readonly USERNAME: BuildFormValidator
8
66357162 9 constructor () {
74d63469 10 this.USERNAME = {
9ccff238 11 VALIDATORS: [ Validators.required, this.localAccountValidator ],
74d63469 12 MESSAGES: {
66357162
C
13 'required': $localize`The username is required.`,
14 'localAccountOnly': $localize`You can only transfer ownership to a local account`
74d63469
GR
15 }
16 }
17 }
9ccff238
LD
18
19 localAccountValidator (control: AbstractControl): ValidationErrors {
20 if (control.value.includes('@')) {
21 return { 'localAccountOnly': true }
22 }
23
24 return null
25 }
74d63469 26}