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