mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-23 07:55:07 +00:00
14 lines
452 B
TypeScript
14 lines
452 B
TypeScript
![]() |
import Joi from "joi";
|
||
|
import { PdfFile } from "./PdfFile";
|
||
|
|
||
|
export const JoiPDFFileSchema = Joi.binary().custom((value: Express.Multer.File[] | PdfFile, helpers) => {
|
||
|
if (!(value instanceof PdfFile)) {
|
||
|
try {
|
||
|
return PdfFile.fromMulterFiles(value);
|
||
|
} catch (error) {
|
||
|
console.error(error);
|
||
|
throw new Error('value is not of type PdfFile');
|
||
|
}
|
||
|
}
|
||
|
return value;
|
||
|
}, "pdffile validation");
|