diff options
Diffstat (limited to 'client/src/app/shared/forms')
3 files changed, 16 insertions, 28 deletions
diff --git a/client/src/app/shared/forms/form-validators/host.validator.ts b/client/src/app/shared/forms/form-validators/host.validator.ts index 03e810fdb..c18a35f9b 100644 --- a/client/src/app/shared/forms/form-validators/host.validator.ts +++ b/client/src/app/shared/forms/form-validators/host.validator.ts | |||
@@ -1,14 +1,8 @@ | |||
1 | import { FormControl } from '@angular/forms' | 1 | export function validateHost (value: string) { |
2 | |||
3 | export function validateHost (c: FormControl) { | ||
4 | // Thanks to http://stackoverflow.com/a/106223 | 2 | // Thanks to http://stackoverflow.com/a/106223 |
5 | const HOST_REGEXP = new RegExp( | 3 | const HOST_REGEXP = new RegExp( |
6 | '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$' | 4 | '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$' |
7 | ) | 5 | ) |
8 | 6 | ||
9 | return HOST_REGEXP.test(c.value) ? null : { | 7 | return HOST_REGEXP.test(value) |
10 | validateHost: { | ||
11 | valid: false | ||
12 | } | ||
13 | } | ||
14 | } | 8 | } |
diff --git a/client/src/app/shared/forms/form-validators/video-abuse.ts b/client/src/app/shared/forms/form-validators/video-abuse.ts index 3c7f26205..4b2a2b789 100644 --- a/client/src/app/shared/forms/form-validators/video-abuse.ts +++ b/client/src/app/shared/forms/form-validators/video-abuse.ts | |||
@@ -3,8 +3,8 @@ import { Validators } from '@angular/forms' | |||
3 | export const VIDEO_ABUSE_REASON = { | 3 | export const VIDEO_ABUSE_REASON = { |
4 | VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(300) ], | 4 | VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(300) ], |
5 | MESSAGES: { | 5 | MESSAGES: { |
6 | 'required': 'Report reason name is required.', | 6 | 'required': 'Report reason is required.', |
7 | 'minlength': 'Report reson must be at least 2 characters long.', | 7 | 'minlength': 'Report reason must be at least 2 characters long.', |
8 | 'maxlength': 'Report reson cannot be more than 300 characters long.' | 8 | 'maxlength': 'Report reason cannot be more than 300 characters long.' |
9 | } | 9 | } |
10 | } | 10 | } |
diff --git a/client/src/app/shared/forms/form-validators/video.ts b/client/src/app/shared/forms/form-validators/video.ts index 65f11f5da..45da7df4a 100644 --- a/client/src/app/shared/forms/form-validators/video.ts +++ b/client/src/app/shared/forms/form-validators/video.ts | |||
@@ -1,5 +1,11 @@ | |||
1 | import { Validators } from '@angular/forms' | 1 | import { Validators } from '@angular/forms' |
2 | 2 | ||
3 | export type ValidatorMessage = { | ||
4 | [ id: string ]: { | ||
5 | [ error: string ]: string | ||
6 | } | ||
7 | } | ||
8 | |||
3 | export const VIDEO_NAME = { | 9 | export const VIDEO_NAME = { |
4 | VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ], | 10 | VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ], |
5 | MESSAGES: { | 11 | MESSAGES: { |
@@ -17,17 +23,13 @@ export const VIDEO_PRIVACY = { | |||
17 | } | 23 | } |
18 | 24 | ||
19 | export const VIDEO_CATEGORY = { | 25 | export const VIDEO_CATEGORY = { |
20 | VALIDATORS: [ Validators.required ], | 26 | VALIDATORS: [ ], |
21 | MESSAGES: { | 27 | MESSAGES: {} |
22 | 'required': 'Video category is required.' | ||
23 | } | ||
24 | } | 28 | } |
25 | 29 | ||
26 | export const VIDEO_LICENCE = { | 30 | export const VIDEO_LICENCE = { |
27 | VALIDATORS: [ Validators.required ], | 31 | VALIDATORS: [ ], |
28 | MESSAGES: { | 32 | MESSAGES: {} |
29 | 'required': 'Video licence is required.' | ||
30 | } | ||
31 | } | 33 | } |
32 | 34 | ||
33 | export const VIDEO_LANGUAGE = { | 35 | export const VIDEO_LANGUAGE = { |
@@ -43,9 +45,8 @@ export const VIDEO_CHANNEL = { | |||
43 | } | 45 | } |
44 | 46 | ||
45 | export const VIDEO_DESCRIPTION = { | 47 | export const VIDEO_DESCRIPTION = { |
46 | VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(3000) ], | 48 | VALIDATORS: [ Validators.minLength(3), Validators.maxLength(3000) ], |
47 | MESSAGES: { | 49 | MESSAGES: { |
48 | 'required': 'Video description is required.', | ||
49 | 'minlength': 'Video description must be at least 3 characters long.', | 50 | 'minlength': 'Video description must be at least 3 characters long.', |
50 | 'maxlength': 'Video description cannot be more than 3000 characters long.' | 51 | 'maxlength': 'Video description cannot be more than 3000 characters long.' |
51 | } | 52 | } |
@@ -58,10 +59,3 @@ export const VIDEO_TAGS = { | |||
58 | 'maxlength': 'A tag should be less than 30 characters long.' | 59 | 'maxlength': 'A tag should be less than 30 characters long.' |
59 | } | 60 | } |
60 | } | 61 | } |
61 | |||
62 | export const VIDEO_FILE = { | ||
63 | VALIDATORS: [ Validators.required ], | ||
64 | MESSAGES: { | ||
65 | 'required': 'Video file is required.' | ||
66 | } | ||
67 | } | ||