# E-OUTR RangeRule Implementation

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

## Overview

This document describes the field-level `RangeRule`, which produces the `E-OUTR` validation message.
The rule checks that each configured field value belongs to the allowed range from the `FIELD.range_id` configuration.

## Rule Description

**Rule Code**: E-OUTR  
**Rule Type**: ERROR  
**Description**: Value out of range  
**Rule Definition ID**: 80  
**Validation Message ID**: 80  
**Protocol**: Incidence (39 var) (Protocol ID: 11)

### Rule Logic

The `E-OUTR` message is produced when:

- The field is included in `ruleToField` for the current protocol and rule.
- The submitted value is not empty.
- The field has a valid configured range.
- The value is valid for datatype and size checks, and is not the field unknown value.
- The value does not belong to the configured range.

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

## Configuration

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

- `target_id = 3` (`SOME_FIELDS`)
- `ruleDefinition_id = 80`
- one row per protocol 11 schema field that had a configured range (`FIELD.range_id > 0`) at migration time

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