Skip to content

Backward route validate#2838

Open
thomasiles wants to merge 8 commits into
mainfrom
backward-route-validate
Open

Backward route validate#2838
thomasiles wants to merge 8 commits into
mainfrom
backward-route-validate

Conversation

@thomasiles

@thomasiles thomasiles commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Add validations to the routes page for backwards routes

Trello card: https://trello.com/c/mwYaCg6h/3137-show-errors-for-backwards-routes-when-multiple-branches-are-enabled

This PR adds backward route validation to the multiple branches routes and page list.

In the routes code, we use new validation. In the page list, we use the Conditions. I think in the long term, the validation should all happen in the routes input which should be used in the page list too. While the feature is still in development, I think using the condition code for now makes sense.

The routes view:

image

The page list view:

image

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

We need to treat errors for routes differently based on page type.

We extract a method which decides whether a page should be treated as a
selection page or not so we can use it when building routes and in other
places too.
To validate that routes are not pointing backwards, we need to know the page that the route is going to.

We add 'goto_page', which is the page the route is pointing to, to the route input.

Default routes and end of form routes don't need to know the page that they're going to.

We still need the goto attribute, which is the page id of the page the
route is pointing to. This is used in the form and can have more values
that just page ids.
Add validation to route which checks that the route is not backwards.
Add validation to routes_input to copy any errors from the routes.
Ensure that Routes are validated when showing the routes page.

This will show the user any errors, which may have been created by
moving pages outside of the routes page.

We also add the correct ID to the select boxes so that errors can be
matched with the correct input.
Add the errors for multiple branches to the entries in the page list.

The only error that is currently shown is for backward routes.

This is added to the page list so that the user can see the error and correct it.

There is only ever one error per page. A selection question with
multiple backward routes will only show one error.
Add multiple branch error summary to page list.
@thomasiles thomasiles force-pushed the backward-route-validate branch from ac9380c to a81376c Compare June 11, 2026 11:56
Comment thread config/locales/en.yml Outdated
@hannahkc

Copy link
Copy Markdown
Contributor

Seems to work correctly and content looks good except for an extra comma. thanks!

@thomasiles thomasiles marked this pull request as ready for review June 11, 2026 12:39
Co-authored-by: Hannah Content <hannah.cooper@digital.cabinet-office.gov.uk>
@thomasiles thomasiles force-pushed the backward-route-validate branch from d4ae2de to 345256d Compare June 11, 2026 13:00
@github-actions

Copy link
Copy Markdown

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-2838.admin.review.forms.service.gov.uk/

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants