Skip to content

Latest commit

 

History

History
103 lines (74 loc) · 3.19 KB

MIGRATION_8.x-9.x.md

File metadata and controls

103 lines (74 loc) · 3.19 KB

Migrating from 8.x to 9.x

The following changes are mandatory:


Mandatory changes

GOVUK Frontend v5 compatibility

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.

casa.mountUrl must not be used for static assets

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" />

Ephemeral contexts must be created from a given request

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);

waypointId removed from field validator condition

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),

Use correct method to retrieve field attributes

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();

PageField.runValidators() signature changed

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" });