diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-20 14:35:18 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-24 14:04:05 +0200 |
commit | d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9 (patch) | |
tree | 4305044c4a97bdf1275b241c63cb0e85151cfb6a /server/helpers/custom-validators/search.ts | |
parent | 57c36b277e68b764dd34cb2e449f6e2ca3d1e9b6 (diff) | |
download | PeerTube-d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9.tar.gz PeerTube-d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9.tar.zst PeerTube-d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9.zip |
Add videos list filters
Diffstat (limited to 'server/helpers/custom-validators/search.ts')
-rw-r--r-- | server/helpers/custom-validators/search.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/search.ts b/server/helpers/custom-validators/search.ts new file mode 100644 index 000000000..2fde39160 --- /dev/null +++ b/server/helpers/custom-validators/search.ts | |||
@@ -0,0 +1,19 @@ | |||
1 | import * as validator from 'validator' | ||
2 | import 'express-validator' | ||
3 | |||
4 | import { isArray } from './misc' | ||
5 | |||
6 | function isNumberArray (value: any) { | ||
7 | return isArray(value) && value.every(v => validator.isInt('' + v)) | ||
8 | } | ||
9 | |||
10 | function isStringArray (value: any) { | ||
11 | return isArray(value) && value.every(v => typeof v === 'string') | ||
12 | } | ||
13 | |||
14 | // --------------------------------------------------------------------------- | ||
15 | |||
16 | export { | ||
17 | isNumberArray, | ||
18 | isStringArray | ||
19 | } | ||