-
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.
feat: editors can select which planning constraints to check (#3968)
- Loading branch information
1 parent
6390a70
commit ea9f33e
Showing
11 changed files
with
967 additions
and
334 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
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 }; |
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
Oops, something went wrong.