Skip to content

Commit

Permalink
Test if suggested transport medium is defined in the record. (#1741)
Browse files Browse the repository at this point in the history
  • Loading branch information
mal-tee authored May 20, 2022
1 parent 304ee72 commit 6aaea30
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/checks/record/suggested-medium-exists.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Check } from '../../types/checks';
import { SuggestedTransportMedium } from '../../types/CompanyRecord';

const check: Check = {
id: 'suggested-medium-exists',
desc: 'The suggested transport medium should be specified in the record.',
url: 'https://github.com/datenanfragen/data/issues/1740',
severity: 'ERROR',
run: (json) => {
if (!('suggested-transport-medium' in json)) return;
const medium = json['suggested-transport-medium'];
if (medium == SuggestedTransportMedium.Letter) return; // this is covered by the schema itself, as records have to have an address.
if (!(medium in json))
return {
message: `Suggested-transport-medium is set to '${medium}', but the ${medium} is not defined in the record.`,
json_pointer: '/suggested-transport-medium',
};
},
};

export default check;

0 comments on commit 6aaea30

Please sign in to comment.