blob: e1a2df8a64f00b23d1c0494f166900a185346018 (
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
|
import { AbstractControl, ValidationErrors, Validators } from '@angular/forms'
import { BuildFormValidator } from './form-validator.model'
export const OWNERSHIP_CHANGE_CHANNEL_VALIDATOR: BuildFormValidator = {
VALIDATORS: [ Validators.required ],
MESSAGES: {
'required': $localize`The channel is required.`
}
}
export const OWNERSHIP_CHANGE_USERNAME_VALIDATOR: BuildFormValidator = {
VALIDATORS: [ Validators.required, localAccountValidator ],
MESSAGES: {
'required': $localize`The username is required.`,
'localAccountOnly': $localize`You can only transfer ownership to a local account`
}
}
function localAccountValidator (control: AbstractControl): ValidationErrors {
if (control.value.includes('@')) {
return { 'localAccountOnly': true }
}
return null
}
|