diff options
Diffstat (limited to 'client/src/app/shared/form-validators/video-ownership-change-validators.ts')
-rw-r--r-- | client/src/app/shared/form-validators/video-ownership-change-validators.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/client/src/app/shared/form-validators/video-ownership-change-validators.ts b/client/src/app/shared/form-validators/video-ownership-change-validators.ts new file mode 100644 index 000000000..e1a2df8a6 --- /dev/null +++ b/client/src/app/shared/form-validators/video-ownership-change-validators.ts | |||
@@ -0,0 +1,25 @@ | |||
1 | import { AbstractControl, ValidationErrors, Validators } from '@angular/forms' | ||
2 | import { BuildFormValidator } from './form-validator.model' | ||
3 | |||
4 | export const OWNERSHIP_CHANGE_CHANNEL_VALIDATOR: BuildFormValidator = { | ||
5 | VALIDATORS: [ Validators.required ], | ||
6 | MESSAGES: { | ||
7 | 'required': $localize`The channel is required.` | ||
8 | } | ||
9 | } | ||
10 | |||
11 | export const OWNERSHIP_CHANGE_USERNAME_VALIDATOR: BuildFormValidator = { | ||
12 | VALIDATORS: [ Validators.required, localAccountValidator ], | ||
13 | MESSAGES: { | ||
14 | 'required': $localize`The username is required.`, | ||
15 | 'localAccountOnly': $localize`You can only transfer ownership to a local account` | ||
16 | } | ||
17 | } | ||
18 | |||
19 | function localAccountValidator (control: AbstractControl): ValidationErrors { | ||
20 | if (control.value.includes('@')) { | ||
21 | return { 'localAccountOnly': true } | ||
22 | } | ||
23 | |||
24 | return null | ||
25 | } | ||