# E-FORM MaxSizeRule Implementation

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

## Overview

This document describes the field-level `MaxSizeRule`, one of the rules producing the `E-FORM` validation message.
The rule checks that each configured field value does not exceed the maximum size from the `FIELD.fieldSize` configuration.

## Rule Description

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

### Rule Logic

The `E-FORM` max-size message is produced when:

- The field is included in `ruleToField` for the current protocol and rule.
- The submitted value is valid for the field datatype.
- The value length is greater than the configured `FIELD.fieldSize`.

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

## Configuration

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

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

This keeps the rule target list visible in database configuration and QCS-ADMIN.
The `FIELD.fieldSize` 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/MaxSizeRule.java`
**Database migration SQL**: `docs/rules/E-FORM/MaxSizeRule/E-FORM-MAXSIZE_rule_registration.sql`
