# E-FORM DataTypeRule Implementation

**HISTORY:**
...
###### 01/07/2026: ECARS-2480 - migrate univariant rules from ALL_FIELDS to SOME_FIELDS

## Overview

This document describes the field-level `DataTypeRule`, one of the rules producing the `E-FORM` validation message.
The rule checks that each configured field value matches the expected datatype from the `FIELD.dataType` configuration.

## Rule Description

**Rule Code**: E-FORM  
**Rule Type**: ERROR  
**Description**: Format error  
**Rule Definition ID**: 60  
**Validation Message ID**: 60  
**Protocol**: Incidence (39 var) (Protocol ID: 11)

### Rule Logic

The `E-FORM` datatype message is produced when:

- The field is included in `ruleToField` for the current protocol and rule.
- The submitted value is not empty.
- The value cannot be parsed according to the field datatype configured in `FIELD.dataType`.

Empty values are accepted by this rule. Missing mandatory values are handled by `MandatoryRule`.

## Configuration

For ENCR protocol 11, `DataTypeRule` uses explicit `ruleToField` targeting:

- `target_id = 3` (`SOME_FIELDS`)
- `ruleDefinition_id = 60`
- one row per protocol 11 schema field

This keeps the rule target list visible in database configuration and QCS-ADMIN. 
The `FIELD.dataType` value remains the validation parameter used by the rule, but it is not used as an implicit target selector for ENCR protocol 11.

## Implementation Files

**Java implementation**: `src/main/java/eu/europa/ec/jrc/qcs/engine/rule/field/DataTypeRule.java`
**Database migration SQL**: `docs/rules/E-FORM/DataTypeRule/EDATATYPE-FORM-DATATYPE_rule_registration.sql`

