diff --git a/CONTRIBUTE.md b/CONTRIBUTING.md
similarity index 100%
rename from CONTRIBUTE.md
rename to CONTRIBUTING.md
diff --git a/README.md b/README.md
index 7c16bb5..7f1b5fc 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
+
Data Validation Engine
@@ -9,49 +9,26 @@
[](https://github.com/NHSDigital/data-validation-engine/actions/workflows/ci_testing.yml)
[](https://github.com/NHSDigital/data-validation-engine/actions/workflows/ci_linting.yml)
-The Data Validation Engine (DVE) is a configuration driven data validation library built and utilised by NHS England. Currently the package has been reverted from v1.0.0 release to a 0.x as we feel the package is not yet mature enough to be considered a 1.0.0 release. So please bear this in mind if reading through the commits and references to a v1+ release when on v0.x.
+The Data Validation Engine (DVE) is a configuration-driven data validation library created and used by NHS England. It lets users define validation rules once and apply them across multiple dataset collections - supporting consistent, accurate data checks.
-As mentioned above, the DVE is "configuration driven" which means the majority of development for you as a user will be building a JSON document to describe how the data will be validated. The JSON document is known as a `dischema` file and example files can be accessed [here](https://github.com/NHSDigital/data-validation-engine/tree/main/tests/testdata). If you'd like to learn more about JSON document and how to build one from scratch, then please read the documentation [here](https://nhsdigital.github.io/data-validation-engine/).
+__The DVE offers__:
-Once a dischema file has been defined, you are ready to use the DVE. The DVE is typically orchestrated based on four key "services". These are...
+- SQL configuration-based validations
+- Format normalization to Parquet for a unified data representation
+- Data modelling and typecasting
+- Business-rule validations executed on supported backends such as Spark and DuckDB, with the option to add custom backends
+- Clear validation reporting, including summary insights and record-level error messages
-| | Service | Purpose |
-| -- | ------- | ------- |
-| 1. | File Transformation | This service will take submitted files and turn them into stringified parquet file(s) to ensure that a consistent data structure can be passed through the other services. |
-| 2. | Data Contract | This service will validate and perform type casting against a stringified parquet file using [pydantic models](https://docs.pydantic.dev/1.10/). |
-| 3. | Business Rules | The business rules service will perform more complex validations such as comparisons between fields and tables, aggregations, filters etc to generate new entities. |
-| 4. | Error Reports | The error reports service will take all the errors raised in previous services and surface them into a readable format for a downstream users/service. Currently, this implemented to be an excel spreadsheet but could be reconfigured to meet other requirements/use cases. |
-
-If you'd like more detailed documentation around these services the please read the extended documentation [here](https://nhsdigital.github.io/data-validation-engine/).
-
-The DVE has been designed in a way that's modular and can support users who just want to utilise specific "services" from the DVE (i.e. just the file transformation + data contract). Additionally, the DVE is designed to support different backend implementations. As part of the base installation of DVE, you will find backend support for `Spark` and `DuckDB`. So, if you need a `MySQL` backend implementation, you can implement this yourself. Given our organisations requirements, it will be unlikely that we add anymore specific backend implementations into the base package beyond Spark and DuckDB. So, if you are unable to implement this yourself, I would recommend reading the guidance on [requesting new features and raising bug reports here](#requesting-new-features-and-raising-bug-reports).
-
-Additionally, if you'd like to contribute a new backend implementation into the base DVE package, then please look at the [Contributing](#Contributing) section.
+As mentioned above, the DVE is "configuration driven" which means the majority of development for you as a user will be building a JSON document to describe how the data will be validated. The JSON document is known as a `dischema` (data ingest schema) file and example files can be accessed [here ↗️](https://github.com/NHSDigital/data-validation-engine/tree/main/tests/testdata). If you'd like to learn more about JSON document and how to build one from scratch, then please read the documentation [here ↗️](https://nhsdigital.github.io/data-validation-engine/).
## Installation and usage
-The DVE is a Python package and can be installed using package managers such as [pip](https://pypi.org/project/pip/). As of the latest release we support Python 3.10 & 3.11, with Spark v3.4 and DuckDB v1.1. In the future we will be looking to upgrade the DVE to working on a higher versions of Python, DuckDB and Spark.
-
-If you're planning to use the Spark backend implementation, you will also need OpenJDK 11 installed.
-
-Python dependencies are listed in `pyproject.toml`.
-
-To install the DVE package you can simply install using a package manager such as [pip](https://pypi.org/project/pip/).
-
-```
-pip install data-validation-engine
-```
-
-*Note - Only versions >=0.6.2 are available on PyPi. For older versions please install directly from the git repo or build from source.*
-
-Once you have installed the DVE you are ready to use it. For guidance on how to create your dischema JSON document (configuration), please read the [documentation](https://nhsdigital.github.io/data-validation-engine/).
-
-Version 0.0.1 does support a working Python 3.7 installation. However, we will not be supporting any issues with that version of the DVE if you choose to use it. __Use at your own risk__.
+Please see the documentation [here ↗️](https://nhsdigital.github.io/data-validation-engine/user_guidance/install/).
## Requesting new features and raising bug reports
**Before creating new issues, please check to see if the same bug/feature has been created already. Where a duplicate is created, the ticket will be closed and referenced to an existing issue.**
-If you have spotted a bug with the DVE then please raise an issue [here](https://github.com/nhsengland/Data-Validation-Engine/issues) using the "bug template".
+If you have spotted a bug with the DVE then please raise an issue [here ↗️](https://github.com/nhsengland/Data-Validation-Engine/issues) using the "bug template".
If you have feature request then please follow the same process whilst using the "Feature request template".
@@ -63,7 +40,7 @@ Below is a list of features that we would like to implement or have been request
| Uplift to Python 3.11 | 0.2.0 | Yes |
| Uplift Pyspark to 3.5 | 0.8.0 | Yes |
| Allow DVE to run on Python 3.12+ | 0.8.0 | Yes |
-| Upgrade to Pydantic 2.0 | 0.9.0 | No |
+| Upgrade to Pydantic 2.0 | 0.9.0 | Yes |
| Uplift Pyspark to 4.0+ | TBA | No |
| Polars upgrade to v1+ | TBA | No |
| DuckDB upgrade to v1.5+ | TBA | No |
@@ -73,7 +50,7 @@ Below is a list of features that we would like to implement or have been request
If you are interested in getting any of the unreleased features listed above available, then please read the [Contributing](#Contributing) section and then submit us a pull request.
## Contributing
-Please see guidance [here](https://github.com/NHSDigital/data-validation-engine/blob/main/CONTRIBUTE.md).
+Please see guidance [here ↗️](https://github.com/NHSDigital/data-validation-engine/blob/main/CONTRIBUTE.md).
## Legal
This codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation.
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 0000000..abb9914
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,23 @@
+# Security
+
+We take security and the protection of private data extremely seriously. If you believe you have found a vulnerability or other issue which has compromised or could compromise the security of any of our systems or private data managed by our systems, please do not hesitate to contact us using the method outlined below.
+
+## Table of contents
+
+- [Security](#security)
+- [Table of contents](#table-of-contents)
+- [Reporting a vulnerability](#reporting-a-vulnerability)
+- [General security enquiries](#general-security-enquiries)
+
+## Reporting a vulnerability
+
+If you believe you have found a security issue in this repository, please report it using GitHub's private vulnerability reporting:
+
+1. [Report a vulnerability](https://github.com/NHSDigital/data-validation-engine/security/advisories/new)
+2. Provide details of the issue and steps to reproduce
+
+This creates a private channel for discussion and allows us to coordinate a fix before any public disclosure.
+
+## General security enquiries
+
+If you have general enquiries regarding our cybersecurity, please reach out to us at [cybersecurity@nhs.net](cybersecurity@nhs.net)
diff --git a/docs/advanced_guidance/json_schemas.md b/docs/advanced_guidance/json_schemas.md
index 5f24bd4..1c65088 100644
--- a/docs/advanced_guidance/json_schemas.md
+++ b/docs/advanced_guidance/json_schemas.md
@@ -17,6 +17,12 @@ For autocomplete support in VS Code, you can alter the `.vscode/settings.json` a
],
"url": "./json_schemas/dataset.schema.json"
},
+ {
+ "fileMatch": [
+ "*_data_contract_error_details.json"
+ ],
+ "url": "./json_schemas/contract/error_details.schema.json"
+ },
{
"fileMatch": [
"*.rulestore.json",
diff --git a/docs/advanced_guidance/json_schemas/contract/contract.schema.json b/docs/advanced_guidance/json_schemas/contract/contract.schema.json
index 97c6162..dad5a92 100644
--- a/docs/advanced_guidance/json_schemas/contract/contract.schema.json
+++ b/docs/advanced_guidance/json_schemas/contract/contract.schema.json
@@ -25,6 +25,10 @@
"additionalProperties": {
"$ref": "components/readable_entity.schema.json"
}
+ },
+ "error_details": {
+ "description": "Relative path from the dischema document to reference a error details document.",
+ "type": "string"
}
},
"additionalProperties": true
diff --git a/docs/advanced_guidance/json_schemas/contract/error_details.schema.json b/docs/advanced_guidance/json_schemas/contract/error_details.schema.json
new file mode 100644
index 0000000..58c369b
--- /dev/null
+++ b/docs/advanced_guidance/json_schemas/contract/error_details.schema.json
@@ -0,0 +1,53 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "data-ingest:error_details.schema.json",
+ "title": "Data Contract Error Details",
+ "type": "object",
+ "patternProperties": {
+ ".*": {
+ "type": "object",
+ "description": "Name of the field defined within the data contract entities.",
+ "properties": {
+ "Bad value": {
+ "$ref": "#/$defs/errorObject",
+ "description": "When a value is incompatiable. e.g. trying to cast 'hello' as int."
+ },
+ "Blank": {
+ "$ref": "#/$defs/errorObject",
+ "description": "When a mandatory value is missing."
+ }
+ }
+ }
+ },
+ "$defs": {
+ "errorObject": {
+ "type": "object",
+ "properties": {
+ "error_code": {
+ "type": "string",
+ "description": "The code you want to report in the error report."
+ },
+ "error_message": {
+ "type": "string",
+ "description": "The error message you want to report in the error report."
+ },
+ "error_level": {
+ "type": "string",
+ "description": "Whether the error should be a record rejection or file/submission rejection. Defaulted to record.",
+ "enum": [
+ "record",
+ "submission"
+ ]
+ },
+ "is_informational": {
+ "type": "boolean",
+ "description": "Whether to raise the error as a warning or not. Defaulted to false."
+ },
+ "reporting_entity": {
+ "type": "string",
+ "description": "Whether to rename the entity shown in the error report. Defaults to the entity name in the dischema."
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/faq.md b/docs/faq.md
new file mode 100644
index 0000000..af25fbe
--- /dev/null
+++ b/docs/faq.md
@@ -0,0 +1,24 @@
+---
+title: Frequently Asked Questions (FAQ)
+tags:
+ - FAQ
+ - Business Rules
+ - Error Reports
+---
+
+??? question "The `id` field in the error report is missing when it should be present?"
+
+ If the `id` field isn't populated then it will be due to the fact that the key field is not present in the entity you are looking up against. The `key_fields`/`key_fields` is sourced from a dictionary lookup sourced in the data contract, so new entities defined within the business_rules won't have this lookup and it will result in the column not being populated. To get around this issue for entities without a defined `key_field` you can use the `original_entity_override` key to define the entity you want to source your `key_field`/`key_fields` from. You may find an example below.
+
+ ??? example
+
+ ```json
+ "filters": [
+ {
+ "entity": "entity_not_defined_in_data_contract",
+ "name": "my rule",
+ "expression": "a < b",
+ "original_entity_override": "entity_defined_in_data_contract"
+ }
+ ]
+ ```
diff --git a/docs/user_guidance/data_contract.md b/docs/user_guidance/data_contract.md
index 55913da..13e72ef 100644
--- a/docs/user_guidance/data_contract.md
+++ b/docs/user_guidance/data_contract.md
@@ -6,11 +6,7 @@ tags:
- Domain Types
---
-The Data Contract defines the structure (models) of your data and controls how it is typecast. We use [Pydantic](https://pydantic.dev/docs/validation/1.10/overview/) to generate and validate the models. This page is meant to give you greater details on how you should write your Data Contract. If you want a summary of how the Data Contract works, please refer to the [Getting Started](./getting_started.md#rules-configuration-introduction) page.
-
-!!! Note
-
- We plan to migrate to Pydantic v2+ in v0.9.0. This page currently reflects what is available through Pydantic v1.
+The Data Contract defines the structure (models) of your data and controls how it is typecast. We use [Pydantic v2](https://pydantic.dev/docs/validation/latest/get-started/) to generate and validate the models. This page is meant to give you greater details on how you should write your Data Contract. If you want a summary of how the Data Contract works, please refer to the [Getting Started](./getting_started.md#rules-configuration-introduction) page.
## Models
@@ -207,15 +203,15 @@ If you want to read more about the readers, please see the [File Transformation]
Within the `fields` section of the contract you must define what data type a given field should be. Depending on how strict/lenient you want your types to be, a number of types are available to use. The types available are:
- [Built-in standard library](https://docs.python.org/3.12/library/stdtypes.html) types (such as `int`, `str`, `date`) available with your version of Python installed for the DVE.
-- [Pydantic v1 types](https://docs.pydantic.dev/1.10/usage/types/)
+- [Pydantic v2 types](https://pydantic.dev/docs/validation/latest/concepts/types/)
- [Custom Types](./data_contract.md#custom-types)
- [Domain types](./data_contract.md#domain-types)
### Constraints
-Given the DVE supports Pydantic types, you can use any of the [constrained types available](https://docs.pydantic.dev/1.10/usage/types/#constrained-types). The Pydantic docs will also show you what `kwarg` arguments are available for each constraint such as min/max length, regex patterns etc.
+The DVE supports constraints against valid python/pydantic types. You can use the `constraints` arguments to apply a specifc constraint such as min/max length etc.
-For example, if you wanted to use a `constr` type for a field, you would define it like this:
+For example, if you wanted to use apply constraints to a `str` type, you may define it like this:
```json title="movies.dischema.json"
{
@@ -225,7 +221,7 @@ For example, if you wanted to use a `constr` type for a field, you would define
"fields": {
"movie_uuid": "int",
"movie_name": {
- "callable": "constr",
+ "callable": "str",
"constraints": {
"min_length": 1,
"max_length": 20
@@ -249,7 +245,7 @@ As shown in the [Constraints](./data_contract.md#constraints) section above, you
{
"types": {
"MyConstrainedString": {
- "callable": "constr",
+ "callable": "str",
"constraints": {
"min_length": 1,
"max_length": 20
@@ -334,7 +330,7 @@ To define a struct type, you would add it to the `types` section like this...
"fields": {
"movie_uuid": "int",
"movie_name": {
- "callable": "constr",
+ "callable": "str",
"constraints": {
"min_length": 1,
"max_length": 20
diff --git a/docs/user_guidance/install.md b/docs/user_guidance/install.md
index e0c2ce4..85186cd 100644
--- a/docs/user_guidance/install.md
+++ b/docs/user_guidance/install.md
@@ -12,7 +12,7 @@ tags:
If working on Python 3.7, the `0.1` release supports this (and only this) version of Python. However, we have not been updating that version with any bugfixes, performance improvements etc. There are also a number of vulnerable dependencies on version `0.1` release due to [Python 3.7 being depreciated](https://devguide.python.org/versions/) and a number of packages dropping support. **If you choose to install `0.1`, you accept the risks of doing so and additional support will not be provided.**
-You can install the DVE package through python package managers such as [pip](https://pypi.org/project/pip/), [pipx](https://github.com/pypa/pipx), [uv](https://docs.astral.sh/uv/) and [poetry](https://python-poetry.org/).
+You can install the DVE package through python package managers such as [pip](https://pypi.org/project/pip/), [uv](https://docs.astral.sh/uv/) and [poetry](https://python-poetry.org/).
=== "pip"
@@ -20,12 +20,6 @@ You can install the DVE package through python package managers such as [pip](ht
pip install data-validation-engine
```
-=== "pipx"
-
- ```sh
- pipx install data-validation-engine
- ```
-
=== "uv"
Add to your existing `uv` project...
@@ -84,10 +78,11 @@ Once you have installed the DVE you are almost ready to use it. To be able to ru
## DVE Version Compatability Matrix
-| DVE Version | Python Version | DuckDB Version | Spark Version | Pydantic Version |
-| ------------ | -------------- | -------------- | ------------- | ---------------- |
-| >=0.8.0 | >=3.10,<3.13 | 1.1.3 | 3.5.2 | 1.10.19 |
-| >=0.7.2 | >=3.10,<3.12 | 1.1.* | 3.4.* | 1.10.16 |
-| >=0.6 | >=3.10,<3.12 | 1.1.* | 3.4.* | 1.10.15 |
-| >=0.2,<0.6 | >=3.10,<3.12 | 1.1.0 | 3.4.4 | 1.10.15 |
-| 0.1 | >=3.7.2,<3.8 | 1.1.0 | 3.2.1 | 1.10.15 |
+| DVE Version | Python Version | DuckDB Version | Spark Version | Pydantic Version |
+| ------------ | -------------- | -------------- | --------------- | ---------------- |
+| >=0.9.0 | >=3.10,<3.13 | 1.1.3 | >=3.5.0,<=3.5.5 | 2.13.4 |
+| >=0.8.0 | >=3.10,<3.13 | 1.1.3 | 3.5.2 | 1.10.19 |
+| >=0.7.2 | >=3.10,<3.12 | 1.1.* | 3.4.* | 1.10.16 |
+| >=0.6 | >=3.10,<3.12 | 1.1.* | 3.4.* | 1.10.15 |
+| >=0.2,<0.6 | >=3.10,<3.12 | 1.1.0 | 3.4.4 | 1.10.15 |
+| 0.1 | >=3.7.2,<3.8 | 1.1.0 | 3.2.1 | 1.10.15 |
diff --git a/pyproject.toml b/pyproject.toml
index f8ae030..8e08264 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -11,7 +11,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
- "Operating System :: OS Independent",
+ "Operating System :: POSIX :: Linux",
"Topic :: Software Development :: Libraries",
"Typing :: Typed",
]
diff --git a/zensical.toml b/zensical.toml
index 255a771..064cb26 100644
--- a/zensical.toml
+++ b/zensical.toml
@@ -67,7 +67,8 @@ nav = [
{"Implementing a new backend" = "advanced_guidance/new_backend.md"},
{"Dischema Language Server" = "advanced_guidance/json_schemas.md"},
]},
- ]}
+ ]},
+ {"FAQ" = "faq.md"}
]
extra_css = ["assets/stylesheets/extra.css"]
# extra_javascript = ["assets/javascript/extra.js"]