]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/custom-validators/follows.ts
Disable openapi generation
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / follows.ts
CommitLineData
4d029ef8 1import { exists, isArray } from './misc'
b8f4167f
C
2import { FollowState } from '@shared/models'
3
4function isFollowStateValid (value: FollowState) {
5 if (!exists(value)) return false
6
7 return value === 'pending' || value === 'accepted'
8}
9
4d029ef8
C
10function isRemoteHandleValid (value: string) {
11 if (!exists(value)) return false
12 if (typeof value !== 'string') return false
13
14 return value.includes('@')
15}
16
17function isEachUniqueHandleValid (handles: string[]) {
18 return isArray(handles) &&
19 handles.every(handle => {
20 return isRemoteHandleValid(handle) && handles.indexOf(handle) === handles.lastIndexOf(handle)
21 })
22}
23
b8f4167f
C
24// ---------------------------------------------------------------------------
25
26export {
4d029ef8
C
27 isFollowStateValid,
28 isRemoteHandleValid,
29 isEachUniqueHandleValid
b8f4167f 30}