diff --git a/api.planx.uk/modules/flows/docs.yaml b/api.planx.uk/modules/flows/docs.yaml index 389ebf4075..d02b1290db 100644 --- a/api.planx.uk/modules/flows/docs.yaml +++ b/api.planx.uk/modules/flows/docs.yaml @@ -56,6 +56,25 @@ components: type: array items: type: string + ValidationCheck: + type: object + properties: + title: + type: string + example: File types + required: true + status: + type: string + enum: + - Pass + - Fail + - Warn + - Not applicable + example: Pass + message: + type: string + example: Your flow has valid file types + required: true responses: CopyFlow: content: @@ -124,19 +143,20 @@ components: properties: message: type: string - required: false - description: - type: string - required: false + required: true alteredNodes: oneOf: - type: array items: $ref: "#/components/schemas/Node" - type: "null" - updatedFlow: - $ref: "#/components/schemas/FlowData" + validationChecks: required: false + oneOf: + - type: array + items: + $ref: "#/components/schemas/ValidationCheck" + - type: "null" FlattenData: content: application/json: diff --git a/api.planx.uk/modules/flows/validate/service.ts b/api.planx.uk/modules/flows/validate/service.ts index 231e001687..802f8f5c9e 100644 --- a/api.planx.uk/modules/flows/validate/service.ts +++ b/api.planx.uk/modules/flows/validate/service.ts @@ -199,9 +199,8 @@ const validateInviteToPay = (flowGraph: FlowGraph): ValidationResponse => { }; const inviteToPayEnabled = (flowGraph: FlowGraph): boolean => { - const payNodes = Object.entries(flowGraph).filter( - (entry): entry is [string, Node] => - isComponentType(entry, ComponentType.Pay), + const payNodes = Object.entries(flowGraph).filter((entry) => + isComponentType(entry, ComponentType.Pay), ); const payNodeStatuses = payNodes.map( ([_nodeId, node]) => node?.data?.allowInviteToPay, @@ -257,9 +256,8 @@ const validateFileTypes = (flowGraph: FlowGraph): ValidationResponse => { }; const getFileUploadNodeFns = (flowGraph: FlowGraph): string[] => { - const fileUploadNodes = Object.entries(flowGraph).filter( - (entry): entry is [string, Node] => - isComponentType(entry, ComponentType.FileUpload), + const fileUploadNodes = Object.entries(flowGraph).filter((entry) => + isComponentType(entry, ComponentType.FileUpload), ); return fileUploadNodes.map(([_nodeId, node]) => node.data?.fn as string); }; @@ -267,12 +265,12 @@ const getFileUploadNodeFns = (flowGraph: FlowGraph): string[] => { const getFileUploadAndLabelNodeFns = (flowGraph: FlowGraph): string[] => { // Exclude Upload & Label nodes used in "info-only" mode with a hidden dropzone const uploadAndLabelNodes = Object.entries(flowGraph).filter( - (entry): entry is [string, Node] => + (entry) => isComponentType(entry, ComponentType.FileUploadAndLabel) && entry[1].data?.hideDropZone !== true, ); const uploadAndLabelFileTypes = uploadAndLabelNodes - .map(([_nodeId, node]) => node.data?.fileTypes) + .map(([_nodeId, node]: [string, Node]) => node.data?.fileTypes) .flat(); return uploadAndLabelFileTypes?.map((file: any) => file?.fn as string); };