[fabric/domain] Remove validator dependency and simplify isInMemoryFile function

This commit is contained in:
Pablo Baleztena 2024-10-14 09:50:01 -03:00
parent b71ecb5de1
commit 3afdb5d230

View File

@ -1,19 +1,14 @@
import { isRecord } from "@fabric/core";
import validator from "validator";
import { InMemoryFile } from "./in-memory-file.js";
const { isBase64, isMimeType } = validator;
export function isInMemoryFile(value: unknown): value is InMemoryFile {
try {
return (
isRecord(value) &&
"data" in value &&
typeof value.data === "string" &&
isBase64(value.data.split(",")[1]) &&
"mimeType" in value &&
typeof value.mimeType === "string" &&
isMimeType(value.mimeType) &&
"name" in value &&
typeof value.name === "string" &&
"sizeInBytes" in value &&