Skip to content

contains

contains(prefix, code): boolean

Tells whether a postcode lies inside another postcode. A postcode contains itself.

Postcode

The larger postcode, such as a district.

Postcode

The postcode to test.

boolean

True when code has each segment of prefix in the same place.

const district = parse('EK-01-A03', { allowPartial: true });
const building = parse('EK-01-A03-FK-01');
if (district.ok && building.ok) {
contains(district.value, building.value); // true
}

Unofficial. Not made or endorsed by NIPOST.