automapper-validation 0.11.0

AHB condition expression parsing, evaluation, and EDIFACT validation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
// <auto-generated>
// Generated by automapper-generator generate-conditions
// AHB: xml-migs-and-ahbs/FV2604/COMDIS_AHB_1_0h_20251001.xml
// Generated: 2026-03-12T11:30:28Z
// </auto-generated>

// LLM-produced bodies aren't idiomatic Rust — silence stylistic lints at
// file scope so `cargo clippy -D warnings` stays green. Correctness,
// suspicious, and perf categories stay on so real bugs still surface.
#![allow(clippy::style, clippy::complexity)]

#[allow(unused_imports)]
use crate::eval::format_validators::*;
use crate::eval::{ConditionEvaluator, ConditionResult, EvaluationContext};

/// Generated condition evaluator for COMDIS FV2604.
pub struct ComdisConditionEvaluatorFV2604 {
    // External condition IDs that require runtime context.
    external_conditions: std::collections::HashSet<u32>,
}

impl Default for ComdisConditionEvaluatorFV2604 {
    fn default() -> Self {
        let mut external_conditions = std::collections::HashSet::new();
        external_conditions.insert(3);
        external_conditions.insert(23);
        external_conditions.insert(24);
        external_conditions.insert(25);
        external_conditions.insert(26);
        external_conditions.insert(27);
        external_conditions.insert(28);
        external_conditions.insert(29);
        external_conditions.insert(30);
        external_conditions.insert(492);
        external_conditions.insert(493);
        Self {
            external_conditions,
        }
    }
}

impl ConditionEvaluator for ComdisConditionEvaluatorFV2604 {
    fn message_type(&self) -> &str {
        "COMDIS"
    }

    fn format_version(&self) -> &str {
        "FV2604"
    }

    fn evaluate(&self, condition: u32, ctx: &EvaluationContext) -> ConditionResult {
        match condition {
            1 => self.evaluate_1(ctx),
            2 => self.evaluate_2(ctx),
            3 => self.evaluate_3(ctx),
            4 => self.evaluate_4(ctx),
            5 => self.evaluate_5(ctx),
            6 => self.evaluate_6(ctx),
            7 => self.evaluate_7(ctx),
            8 => self.evaluate_8(ctx),
            9 => self.evaluate_9(ctx),
            10 => self.evaluate_10(ctx),
            11 => self.evaluate_11(ctx),
            12 => self.evaluate_12(ctx),
            13 => self.evaluate_13(ctx),
            14 => self.evaluate_14(ctx),
            15 => self.evaluate_15(ctx),
            16 => self.evaluate_16(ctx),
            17 => self.evaluate_17(ctx),
            18 => self.evaluate_18(ctx),
            19 => self.evaluate_19(ctx),
            20 => self.evaluate_20(ctx),
            21 => self.evaluate_21(ctx),
            22 => self.evaluate_22(ctx),
            23 => self.evaluate_23(ctx),
            24 => self.evaluate_24(ctx),
            25 => self.evaluate_25(ctx),
            26 => self.evaluate_26(ctx),
            27 => self.evaluate_27(ctx),
            28 => self.evaluate_28(ctx),
            29 => self.evaluate_29(ctx),
            30 => self.evaluate_30(ctx),
            31 => self.evaluate_31(ctx),
            32 => self.evaluate_32(ctx),
            33 => self.evaluate_33(ctx),
            34 => self.evaluate_34(ctx),
            492 => self.evaluate_492(ctx),
            493 => self.evaluate_493(ctx),
            505 => self.evaluate_505(ctx),
            506 => self.evaluate_506(ctx),
            508 => self.evaluate_508(ctx),
            509 => self.evaluate_509(ctx),
            510 => self.evaluate_510(ctx),
            930 => self.evaluate_930(ctx),
            931 => self.evaluate_931(ctx),
            939 => self.evaluate_939(ctx),
            940 => self.evaluate_940(ctx),
            _ => ConditionResult::Unknown,
        }
    }

    fn is_external(&self, condition: u32) -> bool {
        self.external_conditions.contains(&condition)
    }
    fn is_known(&self, condition: u32) -> bool {
        matches!(
            condition,
            1 | 2
                | 3
                | 4
                | 5
                | 6
                | 7
                | 8
                | 9
                | 10
                | 11
                | 12
                | 13
                | 14
                | 15
                | 16
                | 17
                | 18
                | 19
                | 20
                | 21
                | 22
                | 23
                | 24
                | 25
                | 26
                | 27
                | 28
                | 29
                | 30
                | 31
                | 32
                | 33
                | 34
                | 492
                | 493
                | 505
                | 506
                | 508
                | 509
                | 510
                | 930
                | 931
                | 939
                | 940
        )
    }
}

impl ComdisConditionEvaluatorFV2604 {
    /// [1] wenn SG3 AJT+Z61+S_0109 oder SG3 AJT+Z62+S_0109 vorhanden
    fn evaluate_1(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajt_segs = ctx.find_segments("AJT");
        if ajt_segs.is_empty() {
            return ConditionResult::Unknown;
        }
        for seg in &ajt_segs {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str())
                .unwrap_or("");
            let v = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str())
                .unwrap_or("");
            if (q == "Z61" || q == "Z62") && v == "S" {
                return ConditionResult::True;
            }
        }
        ConditionResult::False
    }

    /// [2] wenn SG3 AJT+Z58+S_0109 oder SG3 AJT+Z59+S_0109 oder SG3 AJT+Z60+S_0109 vorhanden
    fn evaluate_2(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajt_segs = ctx.find_segments("AJT");
        if ajt_segs.is_empty() {
            return ConditionResult::Unknown;
        }
        for seg in &ajt_segs {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str())
                .unwrap_or("");
            let v = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str())
                .unwrap_or("");
            if (q == "Z58" || q == "Z59" || q == "Z60") && v == "S" {
                return ConditionResult::True;
            }
        }
        ConditionResult::False
    }

    /// [31] wenn SG3 AJT+Z61+G_0089 oder SG3 AJT+Z62+G_0089 vorhanden
    fn evaluate_31(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajt_segs = ctx.find_segments("AJT");
        if ajt_segs.is_empty() {
            return ConditionResult::Unknown;
        }
        for seg in &ajt_segs {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str())
                .unwrap_or("");
            let v = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str())
                .unwrap_or("");
            if (q == "Z61" || q == "Z62") && v == "G" {
                return ConditionResult::True;
            }
        }
        ConditionResult::False
    }

    /// [32] wenn SG3 AJT+Z58+G_0089 oder SG3 AJT+Z59+G_0089 oder SG3 AJT+Z60+G_0089 vorhanden
    fn evaluate_32(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajt_segs = ctx.find_segments("AJT");
        if ajt_segs.is_empty() {
            return ConditionResult::Unknown;
        }
        for seg in &ajt_segs {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str())
                .unwrap_or("");
            let v = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str())
                .unwrap_or("");
            if (q == "Z58" || q == "Z59" || q == "Z60") && v == "G" {
                return ConditionResult::True;
            }
        }
        ConditionResult::False
    }

    /// [33] wenn SG3 AJT+Z58/Z59/Z60/Z61/Z62+G_0089 vorhanden
    fn evaluate_33(&self, ctx: &EvaluationContext) -> ConditionResult {
        let qualifiers = ["Z58", "Z59", "Z60", "Z61", "Z62"];
        let ajt_segs = ctx.find_segments("AJT");
        if ajt_segs.is_empty() {
            return ConditionResult::Unknown;
        }
        for seg in &ajt_segs {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str())
                .unwrap_or("");
            let v = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str())
                .unwrap_or("");
            if qualifiers.contains(&q) && v == "G" {
                return ConditionResult::True;
            }
        }
        ConditionResult::False
    }

    /// [34] wenn SG3 AJT+A99+G_0089 vorhanden
    fn evaluate_34(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_segment_matching("AJT", &[(0, 0, "A99"), (1, 0, "G")])
    }

    /// [3] Nur MP-ID aus Sparte Strom
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_3(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("mp_id_from_electricity_sector")
    }

    /// [4] wenn SG3 AJT+Z58/Z59/Z60/Z61/Z62+S_0109 vorhanden
    fn evaluate_4(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.find_segments("AJT").iter().any(|seg| {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let p = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(
                q,
                Some("Z58") | Some("Z59") | Some("Z60") | Some("Z61") | Some("Z62")
            ) && p == Some("S")
        }))
    }

    /// [5] wenn SG3 AJT+A01/A02/A03/A04/A06/A07/A09/A12/A15+E_0504 vorhanden
    fn evaluate_5(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.find_segments("AJT").iter().any(|seg| {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let p = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(
                q,
                Some("A01")
                    | Some("A02")
                    | Some("A03")
                    | Some("A04")
                    | Some("A06")
                    | Some("A07")
                    | Some("A09")
                    | Some("A12")
                    | Some("A15")
            ) && p == Some("E")
        }))
    }

    /// [6] wenn SG3 AJT+A07+E_0504 vorhanden
    fn evaluate_6(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.find_segments("AJT").iter().any(|seg| {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let p = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            q == Some("A07") && p == Some("E")
        }))
    }

    /// [7] wenn SG3 AJT+A02+E_0504 vorhanden
    fn evaluate_7(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.find_segments("AJT").iter().any(|seg| {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let p = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            q == Some("A02") && p == Some("E")
        }))
    }

    /// [8] wenn SG3 AJT+A01/A04/A06/A09/A12+E_0504 vorhanden
    fn evaluate_8(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.find_segments("AJT").iter().any(|seg| {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let p = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(
                q,
                Some("A01") | Some("A04") | Some("A06") | Some("A09") | Some("A12")
            ) && p == Some("E")
        }))
    }

    /// [9] wenn SG3 AJT+A05/A10/A11/A14+E_0504 vorhanden
    fn evaluate_9(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.find_segments("AJT").iter().any(|seg| {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let p = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(q, Some("A05") | Some("A10") | Some("A11") | Some("A14")) && p == Some("E")
        }))
    }

    /// [10] wenn SG3 AJT+A03+E_0504 vorhanden
    fn evaluate_10(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.find_segments("AJT").iter().any(|seg| {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let p = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            q == Some("A03") && p == Some("E")
        }))
    }

    /// [11] wenn SG3 AJT+A15+E_0504 vorhanden
    fn evaluate_11(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.find_segments("AJT").iter().any(|seg| {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let p = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            q == Some("A15") && p == Some("E")
        }))
    }

    /// [12] wenn SG3 AJT+A99+S_0109 vorhanden
    fn evaluate_12(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.find_segments("AJT").iter().any(|seg| {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let p = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            q == Some("A99") && p == Some("S")
        }))
    }

    /// [13] wenn SG3 AJT+A07+E_1008 vorhanden
    fn evaluate_13(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.find_segments("AJT").iter().any(|seg| {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let p = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            q == Some("A07") && p == Some("E")
        }))
    }

    /// [14] wenn SG3 AJT+A02+E_1008 vorhanden
    fn evaluate_14(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.find_segments("AJT").iter().any(|seg| {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let p = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            q == Some("A02") && p == Some("E")
        }))
    }

    /// [15] wenn SG3 AJT+A01/A04/A06/A09+E_1008 vorhanden
    fn evaluate_15(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.find_segments("AJT").iter().any(|seg| {
            let q = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let p = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(q, Some("A01") | Some("A04") | Some("A06") | Some("A09")) && p == Some("E")
        }))
    }

    /// [16] wenn SG3 AJT+A03+E_1008 vorhanden
    fn evaluate_16(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("AJT", 0, "A03", 1, 0, &["E_1008"])
    }

    /// [17] wenn SG3 AJT+A15+E_1008 vorhanden
    fn evaluate_17(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("AJT", 0, "A15", 1, 0, &["E_1008"])
    }

    /// [18] wenn SG3 AJT+A05/A10/A11+E_1008 vorhanden
    fn evaluate_18(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajt_segments = ctx.find_segments("AJT");
        let found = ajt_segments.iter().any(|seg| {
            let qual = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let pos = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(qual, Some("A05") | Some("A10") | Some("A11")) && pos == Some("E_1008")
        });
        ConditionResult::from(found)
    }

    /// [19] wenn SG3 AJT+A99+E_0265/E_0271/E_0274/E_0516/E_0520/E_0567 vorhanden
    fn evaluate_19(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value(
            "AJT",
            0,
            "A99",
            1,
            0,
            &["E_0265", "E_0271", "E_0274", "E_0516", "E_0520", "E_0567"],
        )
    }

    /// [20] wenn SG3 AJT+A01/A02/A03/A04/A06/A07/A09/A15+E_1008 vorhanden
    fn evaluate_20(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajt_segments = ctx.find_segments("AJT");
        let found = ajt_segments.iter().any(|seg| {
            let qual = seg
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let pos = seg
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(
                qual,
                Some("A01")
                    | Some("A02")
                    | Some("A03")
                    | Some("A04")
                    | Some("A06")
                    | Some("A07")
                    | Some("A09")
                    | Some("A15")
            ) && pos == Some("E_1008")
        });
        ConditionResult::from(found)
    }

    /// [21] wenn im DE3155 in demselben COM der Code EM vorhanden ist
    fn evaluate_21(&self, ctx: &EvaluationContext) -> ConditionResult {
        let com_segments = ctx.find_segments("COM");
        ConditionResult::from(com_segments.iter().any(|seg| {
            seg.elements
                .first()
                .and_then(|e| e.get(1))
                .map(|s| s.as_str())
                == Some("EM")
        }))
    }

    /// [22] wenn im DE3155 in demselben COM der Code TE / FX / AJ / AL vorhanden ist
    fn evaluate_22(&self, ctx: &EvaluationContext) -> ConditionResult {
        let com_segments = ctx.find_segments("COM");
        ConditionResult::from(com_segments.iter().any(|seg| {
            matches!(
                seg.elements
                    .first()
                    .and_then(|e| e.get(1))
                    .map(|s| s.as_str()),
                Some("TE") | Some("FX") | Some("AJ") | Some("AL")
            )
        }))
    }

    /// [23] Wenn MP-ID in NAD+MS (Nachrichtensender) mit Rolle MSB vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_23(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("sender_is_msb")
    }

    /// [24] Wenn MP-ID in NAD+MR (Nachrichtenempfänger) mit Rolle ESA vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_24(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_esa")
    }

    /// [25] Wenn MP-ID in NAD+MR (Nachrichtenempfänger) mit Rolle LF vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_25(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_lf")
    }

    /// [26] Wenn MP-ID in NAD+MR (Nachrichtenempfänger) mit Rolle NB vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_26(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_nb")
    }

    /// [27] Wenn MP-ID in NAD+MS (Nachrichtensender) mit Rolle NB vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_27(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("sender_is_nb")
    }

    /// [28] Angabe der Datenaustauschreferenz aus der CONTRL
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: Condition states the field contains the data exchange reference from a prior CONTRL message. Whether the COMDIS is responding to a CONTRL cannot be determined from the EDIFACT message content alone — it depends on external business context about which prior message triggered this dispute. (medium confidence)
    fn evaluate_28(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("responding_to_contrl")
    }

    /// [29] Angabe der Datenaustauschreferenz aus der APERAK
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: Condition states the field contains the data exchange reference from a prior APERAK message. Whether the COMDIS is responding to an APERAK cannot be determined from the EDIFACT message content alone — it depends on external business context about which prior message triggered this dispute. (medium confidence)
    fn evaluate_29(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("responding_to_aperak")
    }

    /// [30] Angabe der Nachrichtennummer aus der APERAK
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: Condition states the field contains the message number from a prior APERAK. Like condition 29, whether the COMDIS is responding to an APERAK is external business context, not determinable from message content. Shares the same external predicate as condition 29. (medium confidence)
    fn evaluate_30(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("responding_to_aperak")
    }

    /// [492] Wenn MP-ID in NAD+MR (Nachrichtenempfänger) aus Sparte Strom
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: Whether NAD+MR MP-ID belongs to Sparte Strom cannot be determined from the EDIFACT message content alone — it requires external business context (market participant registry or configuration). (medium confidence)
    fn evaluate_492(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_electricity_sector")
    }

    /// [493] Wenn MP-ID in NAD+MR (Nachrichtenempfänger) aus Sparte Gas
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: Whether NAD+MR MP-ID belongs to Sparte Gas cannot be determined from the EDIFACT message content alone — it requires external business context (market participant registry or configuration). (medium confidence)
    fn evaluate_493(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_gas_sector")
    }

    /// [505] Hinweis: BGM DE1004 aus der vorher per REMADV abgelehnten INVOIC-Nachricht
    fn evaluate_505(&self, _ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::True
    }

    /// [506] Hinweis: BGM DE1004 aus der vorher per IFTSTA abgelehnten MSCONS-Nachricht
    fn evaluate_506(&self, _ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::True
    }

    /// [508] Hinweis: Es darf nur eine Information im DE3148 übermittelt werden
    fn evaluate_508(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Es darf nur eine Information im DE3148 übermittelt werden — informational note, always applies
        ConditionResult::True
    }

    /// [509] Hinweis: Wenn Eingang der zugrundeliegenden Nachricht vor dem 06.06.2025, 00:00 Uhr bestätigt wurde
    fn evaluate_509(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wenn Eingang der zugrundeliegenden Nachricht vor dem 06.06.2025, 00:00 Uhr bestätigt wurde — informational note, always applies
        ConditionResult::True
    }

    /// [510] Hinweis: Wenn Eingang der zugrundeliegenden Nachricht nach dem 06.06.2025, 00:00 Uhr bestätigt wurde
    fn evaluate_510(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wenn Eingang der zugrundeliegenden Nachricht nach dem 06.06.2025, 00:00 Uhr bestätigt wurde — informational note, always applies
        ConditionResult::True
    }

    /// [930] Format: max. 2 Nachkommastellen
    // REVIEW: Format condition for max 2 decimal places. COMDIS carries monetary amounts (MOA) as the primary numeric value segment. Using MOA elements[0][1] for the amount value. (medium confidence)
    fn evaluate_930(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("MOA", 0, 1, |val| validate_max_decimal_places(val, 2))
    }

    /// [931] Format: ZZZ = +00
    fn evaluate_931(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("DTM", 0, 1, validate_timezone_utc)
    }

    /// [939] Format: Die Zeichenkette muss die Zeichen @ und . enthalten
    fn evaluate_939(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("COM", 0, 0, validate_email)
    }

    /// [940] Format: Die Zeichenkette muss mit dem Zeichen + beginnen und danach dürfen nur noch Ziffern folgen
    fn evaluate_940(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("COM", 0, 0, validate_phone)
    }
}