blob: 8c809a0d57b25d08e0fe72d401397d84a55b2919 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import { Injectable } from '@angular/core'
import { AbstractControl, ValidationErrors, Validators } from '@angular/forms'
import { BuildFormValidator } from './form-validator.service'
@Injectable()
export class VideoChangeOwnershipValidatorsService {
readonly USERNAME: BuildFormValidator
constructor () {
this.USERNAME = {
VALIDATORS: [ Validators.required, this.localAccountValidator ],
MESSAGES: {
'required': $localize`The username is required.`,
'localAccountOnly': $localize`You can only transfer ownership to a local account`
}
}
}
localAccountValidator (control: AbstractControl): ValidationErrors {
if (control.value.includes('@')) {
return { 'localAccountOnly': true }
}
return null
}
}
|