The following changes are mandatory:
- GOVUK Frontend v5 compatibility
casa.mountUrl
must not be used for static assets- Ephemeral contexts must be created from a given request
waypointId
removed from field validator condition- Use correct method to retrieve field attributes
PageField.runValidators()
signature changed
CASA v9 includes a major upgrade to the core GOVUK Frontend module, to version 5.
Most applications will not require any migration steps. However, You'll need to review the v5 release notes for any specific guidance on required changes.
Where you may have casa.mountUrl
in your templates to refer to static assets being served on the staticRouter
, you must now use casa.staticMountUrl
. For example:
{# Old #}
<img src={{ casa.mountUrl }}/my-image.png" />
{# New #}
<img src={{ casa.staticMountUrl }}/my-image.png" />
Where you currently call JourneyContext.createEphemeralContext()
, or JourneyContext.fromContext()
, you must now pass the current Express req
request object.
// Old
const ctx1 = JourneyContext.createEphemeralContext();
const ctx2 = JourneyContext.fromContext(otherContext);
// New
const ctx1 = JourneyContext.createEphemeralContext(req);
const ctx2 = JourneyContext.fromContext(otherContext, req);
Field validator condition functions no longer support the waypointId
parameter, after it was deprecated in v8. You should now only use the waypoint
parameter.
// old
field('title').validators([
r.required.make({
errorMsg: 'personal-details:field.title.empty'
}),
]).conditions(({ waypointId }) => true),
// new
field('title').validators([
r.required.make({
errorMsg: 'personal-details:field.title.empty'
}),
]).conditions(({waypoint }) => true),
You must now use the get...()
methods to retrieve field conditions, validators, or processors.
const f = field("name")
.validators([new validator()])
.processors([new processor()])
.conditions([new condition()]);
// Old
validators = f.validators();
processors = f.processors();
conditions = f.conditions();
// New
validators = f.getValidators();
processors = f.getProcessors();
conditions = f.getConditions();
The signature of the PageField.runValidators()
method has changed to remove redundancy.
const f = field("name");
// Old
f.runValidators("Joe Bloggs", { fieldValue: "Joe Bloggs" });
// New
f.runValidators({ fieldValue: "Joe Bloggs" });