1 import { I18n } from '@ngx-translate/i18n-polyfill'
2 import { AbstractControl, ValidationErrors, Validators } from '@angular/forms'
3 import { Injectable } from '@angular/core'
4 import { BuildFormValidator } from '@app/shared'
7 export class VideoChangeOwnershipValidatorsService {
8 readonly USERNAME: BuildFormValidator
10 constructor (private i18n: I18n) {
12 VALIDATORS: [ Validators.required, this.localAccountValidator ],
14 'required': this.i18n('The username is required.'),
15 'localAccountOnly': this.i18n('You can only transfer ownership to a local account')
20 localAccountValidator (control: AbstractControl): ValidationErrors {
21 if (control.value.includes('@')) {
22 return { 'localAccountOnly': true }