Repository navigation
Restore v4 error messages and add error message tests - #498
Open
alexluckett wants to merge 17 commits into
Open
alexluckett wants to merge 17 commits into
alexluckett wants to merge 17 commits into
Conversation
ComponentCollection.validate now uses English when it gets no translator, the same as the component methods. Before, a caller with no translator got i18n keys in the error text, for example "Enter components.addressField.line1". The tests for this showed four errors that users see on v5 forms. These now give the v4 text again: - A number field that is not a number says "must be a number". Before, it said "must include a <label>". - Number, autocomplete and location fields put the label in lowercase in "Enter <label>", the same as other fields. - The error summary keeps the page order. Before, each field with a translated label moved to the end. - A partly filled optional date or month says "must include a month". Before, it showed the key.
The Welsh form test covers 19 question types. These tests add the file upload field, page guidance and the payment field. Each one shows its Welsh text, and its error in Welsh. Html, InsetText, Details and similar content components are not tested, because the forms designer does not translate them.
An optional autocomplete field with a value that is not in the list showed "Enter <label>" when validated with a translator, and "Select <label>" without one. The translated override now matches the constructor, which sets its messages only for a required field. Also correct the 'filees.length' message key to 'files.length'.
The Welsh form tests covered only the required errors. These tests post invalid values to a Welsh form and check the error summary for the min length, pattern, number, email format, checkbox minimum, real date and repeater minimum errors. SummaryViewModel now formats its state errors in the language of the translator rather than in English, so that the errors property agrees with the rest of the view model.
validate always passes a translator, so the checks for a missing translator can never be true. The English path through parent.label is the same text as getTranslatedLabel with the English translator, which uses the same order of error description, short description and title.
The separate map and second loop are not necessary, because fork replaces one field at a time.
The method name and its comment say why fork is used: the field keeps its position, so that the errors stay in page order.
alexluckett
marked this pull request as ready for review
November 17, 2026 19:21
The upload service is stubbed. A single upload returns several files, as when a user selects several files, so that the page can go over its maximum.
Joi names an error type after the schema type, so the file upload and map fields raise array.min, array.max and array.length. No schema has the type files or features, so these keys could never match an error. Each field sets its own array messages, which the file upload limits test shows are the same before and after this change.
…ngine-plugin into fix/v5-validation-messages
The repeat form is a V1 form, so the Welsh test uses its own small V2 repeater form.
The other errors-translated checks repeated the email, checkbox, date and pattern checks in that test, so errors-translated is removed.
|
Scullyon
self-requested a review
November 19, 2026 14:54
Scullyon
approved these changes
Nov 19, 2026
Scullyon
left a comment
Contributor
There was a problem hiding this comment.
Just the one thing to look at, otherwise looks fine to me.
| // Format errors | ||
| this.errors = result.error?.details.map((item) => getError(item, EN_GB)) | ||
| this.errors = result.error?.details.map((item) => | ||
| getError(item, translator.language) |
Contributor
There was a problem hiding this comment.
Claude thinks that dates now follow the session language, whereas the words are still in English.
| 'array.max': messageTemplate.arrayMax, | ||
| 'array.length': messageTemplate.arrayLength, | ||
|
|
||
| 'features.min': messageTemplate.featuresMin, |
Contributor
There was a problem hiding this comment.
I'm sure these had a purpose, it's bugging me but there's no reference to them anymore so 🤷♂️ .
davidjamesstone
approved these changes
Nov 19, 2026
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This change fixes five validation messages that differ from v4 on v5 forms, and gives
ComponentCollection.validatean English default. It also adds Welsh tests for the components and errors that the Welsh form test did not cover.Key changes
NumberFieldusedobjectMissing).objectRequired, which has nolowerFirst). The Welsh text changes in the same way: "Nodwch welsh Number field".schema.keys()moved each field with a translated label to the end.replaceFieldSchemausesschema.fork(), which replaces each field in place.validateuses English when it gets no translator, the same as the component methods. Before, a caller with no translator got keys in the errors, for example "Enter components.addressField.line1". Most of the diff invalidateis indentation, because theif (translator)block is gone. Use "hide whitespace" to review it.overrideParentTitlerequires the translator, becausevalidatealways passes one. The branches for a missing translator are gone. The English text is the same, becauseparent.labelandgetTranslatedLabeluse the same order of error description, short description and title.SummaryViewModelformats the dates in its state errors with the locale of the translator. The message text stays English, because that validation uses the default messages. The summary page replaces these errors with its own page errors, so users see no change.files.*andfeatures.*keys. Joi names an error type after the schema type, so the file upload and map fields raisearray.*, and these keys could never match an error. Each field sets its ownarray.*messages.test/form/file-upload-limits.test.jsshows the same min, max and length errors before and after the removal, in English and Welsh.test/form/components-translated.test.jscovers the file upload field, page guidance and the payment field. The payment error comes fromonSubmitat submission, so that test callsonSubmitdirectly. Html, InsetText and Details have no test, because the forms designer does not translate them.test/form/errors-translated.test.jscovers one error of each other template: text min length, pattern, number, email format, checkbox minimum, real date and the repeater minimum. The real date error is a separate POST, because it shows only when the other fields on the page are valid.test/form/file-upload-limits.test.jscovers the file upload min, max and length errors on a file upload page, with the upload service stubbed. One upload returns several files, as when a user selects several files, so that the page can go over its maximum.