Skip to content

(CM-936) Content design error message tweaks#678

Draft
pezholio wants to merge 9 commits into
mainfrom
CM-936-content-design-tweaks
Draft

(CM-936) Content design error message tweaks#678
pezholio wants to merge 9 commits into
mainfrom
CM-936-content-design-tweaks

Conversation

@pezholio
Copy link
Copy Markdown
Contributor

@pezholio pezholio commented May 21, 2026

This addresses most of the error message suggestions made in the content design review. As most of the errors on required fields are in the format Enter a $thing, I've made some tweaks to make translation lookups more predictable, as well as adding the ability to add the correct indefinite article (a/an) to the field name.

I haven't had chance to check if this addresses all of the suggestions in the document, and may not have chance as today's my last day, so gonna leave this in draft for now.

pezholio added 8 commits May 21, 2026 08:54
This allows us to recursively go through each schema’s subschema and
recursively fetch any fields contained within the subschema. I’ve also
added an `all_nested_fields` method to the `Field` class to fetch any
nested fields inside each field.

This will allow us to be able to fetch fields from the validation
context to make translation easier.
This accepts an `error_type` argument, and builds up the I18n path
to fetch a translated error message, falling back to the default error
message for a particular error type. It also accepts additional
arguments, which can be used in interpolation.
This updates the validator to fetch a field object based on an ID, and
fetch the error message from the field, meaning we have to do less
jiggery pokery with the translations from within the validator, and make
the lookups more specific.
Most of the suggested error message copy comes in the format:

```
Enter a/an $attribute
```

To save having to add translations for every field in this vein,
we update the `error_message` translation to send the attribute prefixed
with an indefinite article (a/an) using the existing
`add_indefinite_article` helper method.

We also `downcase` the atrribute name to avoid the issue of having
capital letters in the middle of sentences.
Not all translations will use the default quite so easily, so let’s add
these ones manually
@pezholio pezholio changed the title (CM-936) Content design tweaks (CM-936) Content design error message tweaks May 21, 2026
@pezholio pezholio force-pushed the CM-936-content-design-tweaks branch 2 times, most recently from 4160a51 to b617f2d Compare May 21, 2026 14:38
This ensures that when a title is missing, the correct translation
is used for the title field, rather than `Enter a title` and
`Title must include as least one letter or number`

I’ve also had to set the error message `format` to just return the
`message`, rather than prefixing with the attribute, otherwise we
would see `Title contact name must include at least one letter or number`
@pezholio pezholio force-pushed the CM-936-content-design-tweaks branch from b617f2d to 8a43861 Compare May 21, 2026 14:49
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.

1 participant