diff options
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r-- | server/helpers/custom-validators/users.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index b5b5642d6..159c2a700 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts | |||
@@ -21,10 +21,18 @@ function isUserUsernameValid (value: string) { | |||
21 | return exists(value) && validator.matches(value, new RegExp(`^[a-z0-9._]{${min},${max}}$`)) | 21 | return exists(value) && validator.matches(value, new RegExp(`^[a-z0-9._]{${min},${max}}$`)) |
22 | } | 22 | } |
23 | 23 | ||
24 | function isUserDisplayNSFWValid (value: any) { | 24 | function isBoolean (value: any) { |
25 | return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) | 25 | return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) |
26 | } | 26 | } |
27 | 27 | ||
28 | function isUserDisplayNSFWValid (value: any) { | ||
29 | return isBoolean(value) | ||
30 | } | ||
31 | |||
32 | function isUserAutoPlayVideoValid (value: any) { | ||
33 | return isBoolean(value) | ||
34 | } | ||
35 | |||
28 | function isUserRoleValid (value: any) { | 36 | function isUserRoleValid (value: any) { |
29 | return exists(value) && validator.isInt('' + value) && UserRole[value] !== undefined | 37 | return exists(value) && validator.isInt('' + value) && UserRole[value] !== undefined |
30 | } | 38 | } |
@@ -36,5 +44,6 @@ export { | |||
36 | isUserRoleValid, | 44 | isUserRoleValid, |
37 | isUserVideoQuotaValid, | 45 | isUserVideoQuotaValid, |
38 | isUserUsernameValid, | 46 | isUserUsernameValid, |
39 | isUserDisplayNSFWValid | 47 | isUserDisplayNSFWValid, |
48 | isUserAutoPlayVideoValid | ||
40 | } | 49 | } |