diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2018-10-12 18:12:39 +0200 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2018-10-13 11:53:48 +0200 |
commit | ed638e5325096ef580da20f370ac61c59cd48cf7 (patch) | |
tree | 8ad4c1001efb3adc3946a6b6c9a3c1ed1f557995 /server/helpers/custom-validators | |
parent | 64cc5e8575fda47b281ae20abf0020e27fc8ce7c (diff) | |
download | PeerTube-ed638e5325096ef580da20f370ac61c59cd48cf7.tar.gz PeerTube-ed638e5325096ef580da20f370ac61c59cd48cf7.tar.zst PeerTube-ed638e5325096ef580da20f370ac61c59cd48cf7.zip |
move to boolean switch
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r-- | server/helpers/custom-validators/users.ts | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 2024d4a22..1cb5e5b0f 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import 'express-validator' | 1 | import 'express-validator' |
2 | import * as validator from 'validator' | 2 | import * as validator from 'validator' |
3 | import { UserRole } from '../../../shared' | 3 | import { UserRole } from '../../../shared' |
4 | import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES, WEBTORRENT_POLICY_TYPES } from '../../initializers' | 4 | import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers' |
5 | import { exists, isFileValid, isBooleanValid } from './misc' | 5 | import { exists, isFileValid, isBooleanValid } from './misc' |
6 | import { values } from 'lodash' | 6 | import { values } from 'lodash' |
7 | 7 | ||
@@ -42,9 +42,8 @@ function isUserNSFWPolicyValid (value: any) { | |||
42 | return exists(value) && nsfwPolicies.indexOf(value) !== -1 | 42 | return exists(value) && nsfwPolicies.indexOf(value) !== -1 |
43 | } | 43 | } |
44 | 44 | ||
45 | const webTorrentPolicies = values(WEBTORRENT_POLICY_TYPES) | 45 | function isUserWebTorrentEnabledValid (value: any) { |
46 | function isUserWebTorrentPolicyValid (value: any) { | 46 | return isBooleanValid(value) |
47 | return exists(value) && webTorrentPolicies.indexOf(value) !== -1 | ||
48 | } | 47 | } |
49 | 48 | ||
50 | function isUserAutoPlayVideoValid (value: any) { | 49 | function isUserAutoPlayVideoValid (value: any) { |
@@ -83,7 +82,7 @@ export { | |||
83 | isUserUsernameValid, | 82 | isUserUsernameValid, |
84 | isUserEmailVerifiedValid, | 83 | isUserEmailVerifiedValid, |
85 | isUserNSFWPolicyValid, | 84 | isUserNSFWPolicyValid, |
86 | isUserWebTorrentPolicyValid, | 85 | isUserWebTorrentEnabledValid, |
87 | isUserAutoPlayVideoValid, | 86 | isUserAutoPlayVideoValid, |
88 | isUserDisplayNameValid, | 87 | isUserDisplayNameValid, |
89 | isUserDescriptionValid, | 88 | isUserDescriptionValid, |