LADTI

Destination type is invalid

This check flags invalid destination codes based on the list of valid codes maintained in the public.destination_type table from published Regulations and Circulars.

-- © Copyright 2026 The Kahawai Collective
-- SPDX-License-Identifier: MIT
INSERT INTO grooming_rules
VALUES ('LADTI', 'edw', 'landings', 'Flag', 'Invalid landing destination');

CREATE OR REPLACE FUNCTION LADTI() RETURNS VOID AS $$

INSERT INTO groomed.checks(code, "table", "column", id)
SELECT 'LADTI', 'landings', 'destination_type', id
FROM   groomed.landings
WHERE destination_type NOT IN (SELECT code FROM public.destination_type);

UPDATE groomed.landings
SET    checks=array_append(checks, 'LADTI')
WHERE  id IN (SELECT id FROM groomed.checks WHERE code = 'LADTI');

$$ LANGUAGE SQL;

SELECT LADTI();
Effects of grooming
Figure 1: The number of records affected by the LADTI rule, by year and source.
Figure 2: The proportion of records affected by the LADTI rule, by form type, for all form types where some records are groomed by the LADTI rule.