summaryrefslogtreecommitdiffhomepage
path: root/frontend/src/utilites/validate.ts
blob: 9c34d04be578c81ea568d63605c2ee318140fd1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { isNull, isNumber, isString, isUndefined } from "lodash";
import { ReactText } from "react";

export function isReactText(v: any): v is ReactText {
  return isString(v) || isNumber(v);
}

export function isNullable(v: any): v is Nullable<any> {
  return isNull(v) || isUndefined(v);
}

export function isNonNullable(v: any): v is NonNullable<any> {
  return !isNullable(v);
}

export function isMovie(v: any): v is Item.Movie {
  return "radarrId" in v;
}

export function isEpisode(v: any): v is Item.Episode {
  return "sonarrEpisodeId" in v;
}

export function isSeries(v: any): v is Item.Series {
  return "episodeFileCount" in v;
}