diff options
author | Gérald Niel <gerald.niel@gegeweb.org> | 2018-04-19 19:28:55 +0200 |
---|---|---|
committer | Gérald Niel <gerald.niel@gegeweb.org> | 2018-04-19 19:28:55 +0200 |
commit | 0db1a226507a39b0a663e3e63f04851836a44d5a (patch) | |
tree | 8c8dad658ea5608afaae238cfb6fe803292f908f /server/helpers/custom-validators/users.ts | |
parent | 0030284b0df2983914291d6fe83675e2aa892e6a (diff) | |
parent | d4f3fea659163749f9ea879a5e1dd313106353c6 (diff) | |
download | PeerTube-0db1a226507a39b0a663e3e63f04851836a44d5a.tar.gz PeerTube-0db1a226507a39b0a663e3e63f04851836a44d5a.tar.zst PeerTube-0db1a226507a39b0a663e3e63f04851836a44d5a.zip |
Merge branch 'develop' of framagit.org:chocobozzz/PeerTube into develop
Diffstat (limited to 'server/helpers/custom-validators/users.ts')
-rw-r--r-- | server/helpers/custom-validators/users.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index bbc7cc199..c0acb8218 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts | |||
@@ -1,9 +1,10 @@ | |||
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 } from '../../initializers' | 4 | import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers' |
5 | 5 | ||
6 | import { exists, isFileValid } from './misc' | 6 | import { exists, isFileValid } from './misc' |
7 | import { values } from 'lodash' | ||
7 | 8 | ||
8 | const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS | 9 | const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS |
9 | 10 | ||
@@ -29,8 +30,9 @@ function isBoolean (value: any) { | |||
29 | return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) | 30 | return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) |
30 | } | 31 | } |
31 | 32 | ||
32 | function isUserDisplayNSFWValid (value: any) { | 33 | const nsfwPolicies = values(NSFW_POLICY_TYPES) |
33 | return isBoolean(value) | 34 | function isUserNSFWPolicyValid (value: any) { |
35 | return exists(value) && nsfwPolicies.indexOf(value) !== -1 | ||
34 | } | 36 | } |
35 | 37 | ||
36 | function isUserAutoPlayVideoValid (value: any) { | 38 | function isUserAutoPlayVideoValid (value: any) { |
@@ -56,7 +58,7 @@ export { | |||
56 | isUserRoleValid, | 58 | isUserRoleValid, |
57 | isUserVideoQuotaValid, | 59 | isUserVideoQuotaValid, |
58 | isUserUsernameValid, | 60 | isUserUsernameValid, |
59 | isUserDisplayNSFWValid, | 61 | isUserNSFWPolicyValid, |
60 | isUserAutoPlayVideoValid, | 62 | isUserAutoPlayVideoValid, |
61 | isUserDescriptionValid, | 63 | isUserDescriptionValid, |
62 | isAvatarFile | 64 | isAvatarFile |