# Data Validation Layers

## Validation Layers

### 1. Excel-Level Validation (Client-Side)

Excel templates contain embedded validation rules that prevent incorrect or incomplete data from being entered at the source. Some of the validations are mentioned below.

* Regular expressions (regex)
* Mandatory field checks
* Drop-down values
* Unique value validations

### 2. MDMS Schema-Level Validation (Server-Side)

The following activities are executed at the server side once the Excel file is uploaded through Jupyter Notebook-

* The MDMS service validates the data against the predefined schemas.
* It validates for the following-
  * Mandatory fields
  * Data types
  * Enum validations
  * Pattern (regex) constraints
  * Cross-field and cross-sheet relationships
  * Foreign key references
  * Uniqueness at the schema level
* Invalid rows are rejected, and detailed error messages are returned.

### 3. API-Level Validation (Backend Service Validation)

Once the data passes schema validation, the loader sends it to the appropriate backend services (MDMS, Boundary Service, CRS Master APIs). These services perform the final checks and dependencies at the backend. A few of the validations are as below-

* Duplicate records in the database
* Boundary parent-child hierarchy validation
* Department to designation mapping
* Complaint to the department mapping
* System-level constraints that are defined(Example, invalid tenant ID)

Any failures at this layer are returned in the processed Excel file with appropriate error codes and descriptions.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digit.org/complaints-management/complaints-resolution-v2.10/deploy/setup/production-setup/deploy-complaints-management/data-validation-layers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
