Coding Guidelines

These guidelines have been produced to assist in the creation of validation scripts that will be compatible with data processors in the Lintol application. Validation scripts can be written in various programming languages including Python, C, json and Ruby. The script requires a standardised output that will allow the results of the script to be consumed by the Lintol application.

Data Processor

A data processor is an entity that contains a reference to a script that can validate an aspect of a dataset and a reference to the dataset that is to be validated.

JSON schema

This JSON schema defines the required output from a validation script that will be readable and consumable by the Lintol application.

Root Object

Example

    {
      "version": 1,
      "item-count": 0,
      "counts": {},
      "valid": false,
      "issues-skipped": {},
      "artifacts": {},
      "tables": [],
      "filename": "",
      "preset": "",
      "table-count": 1,
      "time": 0,
      "supplementary":[]
    }

Tables Object

Example

    "tables": [
      {
        "format": "csv",
        "errors": [],
        "warnings": [],
        "informations": [],
        "headers": [],
        "source": "",
        "time": 0,
        "valid": false,
        "scheme": "",
        "encoding": "",
        "schema": null,
        "item-count": 0,
        "error-count": 0,
        "warning-count": 0,
        "information-count": 0
      }
    ]

Information, Warning and Error Object

Example

    "info": [
      {
        "processor": "",
        "code": "",
        "message": "",
        "item": {},
        "context": [],
        "error-data": {}
      }
    ]

Item Object

Example

    "item": {
      "entity": {
        "type": "Cell",
        "location": {
            "row": 1,
            "column": 1
        },
        "definition": ""
      },
      "properties": {
        "_content": ""
      }
    }

Context Object

Example

    "context": [
      "item": {
        "entity": {
          "type": "Row",
          "location": {
              "row": 1,
              "column": null
          },
          "definition": ""
        },
        "properties": {
          "_content": ""
        }
      }
    ]

Supplementary Object

Example

    "supplementary": [
      {
        "type": "",
        "source": "",
        "name": ""
      }
    ]

Minimum Sample Schema

    {
      "version": 1,
      "item-count": 0,
      "counts": {
        "errors": 0,
        "warnings": 0,
        "informations": 0,
      },
      "valid": false,
      "issues-skipped": {},
      "artifacts": {},
      "tables": [],
      "filename": "source_data.csv",
      "preset": "tabular",
      "table-count": 1,
      "time": 10,
      "supplementary":[]
    }

Full Example Schema

    {
      "supplementary": [],
      "item-count": 200,
      "error-count": 200,
      "counts": {
        "errors": 100,
        "warnings": 100,
        "informations": 0
      },
      "valid": false,
      "issues-skipped": {
        "dfi/resource-defects:1|missing-official-section-code": [
          1904,
          100,
          2004
        ]
      },
      "artifacts": {
        "dfi/resource-defects:1#report:csv": {
          "uri": "doorstep/doorstep-508b60b7-0e04-465e-843c-70daff6e064c/b6f231ce-0ca6-462c-97ae-dddd04b342b5/artifact_0",
          "is_bytes": false,
          "mime": "text/csv",
          "encoding": "utf-8"
        }
      },
      "tables": [
        {
          "format": "csv",
          "errors": [
            {
              "processor": "dfi/resource-defects:1",
              "code": "missing-official-section-code",
              "message": "The section code (prefix for SECTION_NAME) in this row is not found in the official list",
              "item": {
                "entity": {},
                "properties": null
              },
              "context": [
                {
                  "entity": {},
                  "properties": null
                }
              ],
              "error-data": {
                "export-columns": [
                  [
                    "SECTION_CODE",
                    "7125A0509_04"
                  ]
                ]
              }
            },
          ],
          "warnings": [],
          "informations": [],
          "row-count": null,
          "headers": [
            "INSTRUCTION_REFERENCE",
            "DEFECT_DETAIL",
            "SECTION_NAME",
            "DIVISION",
            "SECTION_OFFICE",
            "RECORDED_DATE",
            "DEFECT_STATUS",
            "EASTING",
            "NORTHING",
            "SECTION_CODE",
            "OFF_SECTION_NAME"
          ],
          "source": "Surface_Defects_2016.csv",
          "time": 0,
          "valid": false,
          "scheme": "file",
          "encoding": "utf-8",
          "schema": null,
          "item-count": 200,
          "error-count": 100,
          "warning-count": 100,
          "information-count": 100
        }
      ],
      "filename": "Surface_Defects_2016.csv",
      "preset": "tabular",
      "warnings": [],
      "table-count": 1,
      "time": 0
    }