-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into jh/actual-or-work
- Loading branch information
Showing
70 changed files
with
3,773 additions
and
2,711 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
api.planx.uk/modules/flows/validate/service/planningConstraints.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
ComponentType, | ||
type FlowGraph, | ||
} from "@opensystemslab/planx-core/types"; | ||
import { numberOfComponentType } from "../helpers.js"; | ||
import type { FlowValidationResponse } from "./index.js"; | ||
|
||
const validatePlanningConstraints = ( | ||
flowGraph: FlowGraph, | ||
): FlowValidationResponse => { | ||
const numberOfPlanningConstraintNodes = numberOfComponentType( | ||
flowGraph, | ||
ComponentType.PlanningConstraints, | ||
); | ||
if (numberOfPlanningConstraintNodes > 1) { | ||
return { | ||
title: "Planning Constraints", | ||
status: "Fail", | ||
message: | ||
"When using Planning Constraints, your flow must have exactly ONE Planning Constraints component", | ||
}; | ||
} else if (numberOfPlanningConstraintNodes === 1) { | ||
// In future, add extra `hasPlanningData` validation step here to ensure integration is available for this team | ||
return { | ||
title: "Planning Constraints", | ||
status: "Pass", | ||
message: "Your flow has valid Planning Constraints", | ||
}; | ||
} else { | ||
return { | ||
title: "Planning Constraints", | ||
status: "Not applicable", | ||
message: "Your flow is not using Planning Constraints", | ||
}; | ||
} | ||
}; | ||
|
||
export { validatePlanningConstraints }; |
Oops, something went wrong.