class IncorrectFileFormat extends Data.TaggedClass("IncorrectFileFormat")<{
readonly custom: string;
}> {}
export const supportableFormats = [".webp" as const, ".png" as const, ".jpg" as const];
export const splitPathAndFormat = (path: string) => {
const splitPathArray = path.split(".");
const splitPath = splitPathArray.slice(0, -1).join(".");
const format = `.${splitPathArray[splitPathArray.length - 1]}` as (typeof supportableFormats)[number];
return supportableFormats.includes(format)
? Effect.succeed({
splitPath: splitPath,
format: format,
})
: Effect.fail(
new IncorrectFileFormat({
custom: `There was not an acceptable format per the supportableFormats: ${supportableFormats}`,
})
);
};
class IncorrectFileFormat extends Data.TaggedClass("IncorrectFileFormat")<{
readonly custom: string;
}> {}
export const supportableFormats = [".webp" as const, ".png" as const, ".jpg" as const];
export const splitPathAndFormat = (path: string) => {
const splitPathArray = path.split(".");
const splitPath = splitPathArray.slice(0, -1).join(".");
const format = `.${splitPathArray[splitPathArray.length - 1]}` as (typeof supportableFormats)[number];
return supportableFormats.includes(format)
? Effect.succeed({
splitPath: splitPath,
format: format,
})
: Effect.fail(
new IncorrectFileFormat({
custom: `There was not an acceptable format per the supportableFormats: ${supportableFormats}`,
})
);
};