[fabric/domain] Remove validator dependency and simplify isInMemoryFile function
This commit is contained in:
parent
b71ecb5de1
commit
3afdb5d230
@ -1,19 +1,14 @@
|
|||||||
import { isRecord } from "@fabric/core";
|
import { isRecord } from "@fabric/core";
|
||||||
import validator from "validator";
|
|
||||||
import { InMemoryFile } from "./in-memory-file.js";
|
import { InMemoryFile } from "./in-memory-file.js";
|
||||||
|
|
||||||
const { isBase64, isMimeType } = validator;
|
|
||||||
|
|
||||||
export function isInMemoryFile(value: unknown): value is InMemoryFile {
|
export function isInMemoryFile(value: unknown): value is InMemoryFile {
|
||||||
try {
|
try {
|
||||||
return (
|
return (
|
||||||
isRecord(value) &&
|
isRecord(value) &&
|
||||||
"data" in value &&
|
"data" in value &&
|
||||||
typeof value.data === "string" &&
|
typeof value.data === "string" &&
|
||||||
isBase64(value.data.split(",")[1]) &&
|
|
||||||
"mimeType" in value &&
|
"mimeType" in value &&
|
||||||
typeof value.mimeType === "string" &&
|
typeof value.mimeType === "string" &&
|
||||||
isMimeType(value.mimeType) &&
|
|
||||||
"name" in value &&
|
"name" in value &&
|
||||||
typeof value.name === "string" &&
|
typeof value.name === "string" &&
|
||||||
"sizeInBytes" in value &&
|
"sizeInBytes" in value &&
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user