]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/helpers/custom-validators/misc.ts
Add lazy description on server
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / misc.ts
... / ...
CommitLineData
1import * as validator from 'validator'
2
3function exists (value: any) {
4 return value !== undefined && value !== null
5}
6
7function isArray (value: any) {
8 return Array.isArray(value)
9}
10
11function isDateValid (value: string) {
12 return exists(value) && validator.isISO8601(value)
13}
14
15function isIdValid (value: string) {
16 return exists(value) && validator.isInt('' + value)
17}
18
19function isUUIDValid (value: string) {
20 return exists(value) && validator.isUUID('' + value, 4)
21}
22
23function isIdOrUUIDValid (value: string) {
24 return isIdValid(value) || isUUIDValid(value)
25}
26
27// ---------------------------------------------------------------------------
28
29export {
30 exists,
31 isArray,
32 isIdValid,
33 isUUIDValid,
34 isIdOrUUIDValid,
35 isDateValid
36}