]>
Commit | Line | Data |
---|---|---|
1 | import { exists } from './misc' | |
2 | import * as validator from 'validator' | |
3 | import { CONSTRAINTS_FIELDS, VIDEO_PLAYLIST_PRIVACIES, VIDEO_PLAYLIST_TYPES } from '../../initializers/constants' | |
4 | import * as express from 'express' | |
5 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | |
6 | ||
7 | const PLAYLISTS_CONSTRAINT_FIELDS = CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS | |
8 | ||
9 | function isVideoPlaylistNameValid (value: any) { | |
10 | return exists(value) && validator.isLength(value, PLAYLISTS_CONSTRAINT_FIELDS.NAME) | |
11 | } | |
12 | ||
13 | function isVideoPlaylistDescriptionValid (value: any) { | |
14 | return value === null || (exists(value) && validator.isLength(value, PLAYLISTS_CONSTRAINT_FIELDS.DESCRIPTION)) | |
15 | } | |
16 | ||
17 | function isVideoPlaylistPrivacyValid (value: number) { | |
18 | return validator.isInt(value + '') && VIDEO_PLAYLIST_PRIVACIES[ value ] !== undefined | |
19 | } | |
20 | ||
21 | function isVideoPlaylistTimestampValid (value: any) { | |
22 | return value === null || (exists(value) && validator.isInt('' + value, { min: 0 })) | |
23 | } | |
24 | ||
25 | function isVideoPlaylistTypeValid (value: any) { | |
26 | return exists(value) && VIDEO_PLAYLIST_TYPES[ value ] !== undefined | |
27 | } | |
28 | ||
29 | // --------------------------------------------------------------------------- | |
30 | ||
31 | export { | |
32 | isVideoPlaylistNameValid, | |
33 | isVideoPlaylistDescriptionValid, | |
34 | isVideoPlaylistPrivacyValid, | |
35 | isVideoPlaylistTimestampValid, | |
36 | isVideoPlaylistTypeValid | |
37 | } |