mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-22 23:45:02 +00:00
commented ts-typeguard & improved validation error
This commit is contained in:
parent
8d9c24b09b
commit
f87fb32913
@ -36,8 +36,8 @@ export function validateOperations(actions: Action[]): { valid: boolean, reason?
|
||||
|
||||
for (const afterDoneChild of done[childAction.values.id]?.actions || []) {
|
||||
const receivingOperator = getOperatorByName(afterDoneChild.type);
|
||||
if (!receivingOperator) {
|
||||
return { valid: false, reason: `The receiving operator ${afterDoneChild.type} does not exist.` };
|
||||
if (receivingOperator === undefined) {
|
||||
return { valid: false, reason: `action.type ${afterDoneChild.type} does not exist.` };
|
||||
} else if (!ioCompatible(operator, receivingOperator)) {
|
||||
return { valid: false, reason: `Ouput of action ${action.type} is not compatible with input of action ${afterDoneChild.type}` };
|
||||
}
|
||||
@ -48,8 +48,8 @@ export function validateOperations(actions: Action[]): { valid: boolean, reason?
|
||||
}
|
||||
else {
|
||||
const receivingOperator = getOperatorByName(childAction.type);
|
||||
if (!receivingOperator) {
|
||||
return { valid: false, reason: `The receiving operator ${childAction.type} does not exist.` };
|
||||
if (receivingOperator === undefined) {
|
||||
return { valid: false, reason: `action.type ${childAction.type} does not exist.` };
|
||||
} else if (!ioCompatible(operator, receivingOperator)) {
|
||||
return { valid: false, reason: `Ouput of action ${action.type} is not compatible with input of action ${childAction.type}` };
|
||||
}
|
||||
|
@ -22,6 +22,6 @@ export const JoiPDFFileSchema = Joi.custom((value: Express.Multer.File[] /* <- a
|
||||
}
|
||||
}, "pdffile validation");
|
||||
|
||||
function isPdfFileArray(value: any): value is PdfFile[] {
|
||||
return value.every((e: PdfFile) => e instanceof PdfFile)
|
||||
}
|
||||
function isPdfFileArray(value: any[]): value is PdfFile[] { // "is" is a ts-typeguard - https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
||||
return value.every((e) => e instanceof PdfFile)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user