summaryrefslogtreecommitdiffhomepage
path: root/frontend/src/utilities/validate.ts
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/utilities/validate.ts')
-rw-r--r--frontend/src/utilities/validate.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/frontend/src/utilities/validate.ts b/frontend/src/utilities/validate.ts
new file mode 100644
index 000000000..9c34d04be
--- /dev/null
+++ b/frontend/src/utilities/validate.ts
@@ -0,0 +1,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;
+}