-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidation_result.py
More file actions
48 lines (39 loc) · 1.22 KB
/
validation_result.py
File metadata and controls
48 lines (39 loc) · 1.22 KB
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
"""
ValidationResult - Immutable DTO for validation results
NORP Compliance:
- NORP-003: Immutable DTO (frozen dataclass)
- NORP-001: Validation result structure
- NORP-007: Cost estimation included
License: MIT
Copyright: 2026 NeuraScope CONVERWAY
"""
from dataclasses import dataclass
from typing import List
@dataclass(frozen=True)
class ValidationResult:
"""
Immutable validation result (NORP-003 compliant)
"""
valid: bool
errors: List[str]
warnings: List[str]
estimated_cost: float = 0.0
def has_critical_errors(self) -> bool:
"""Check if critical errors are present"""
return not self.valid and len(self.errors) > 0
def to_dict(self) -> dict:
"""Convert to dictionary for serialization"""
return {
'valid': self.valid,
'errors': self.errors,
'warnings': self.warnings,
'estimated_cost': self.estimated_cost
}
def get_summary(self) -> str:
"""Get summary message"""
if self.valid:
msg = 'Validation passed'
if self.warnings:
msg += f' ({len(self.warnings)} warnings)'
return msg
return 'Validation failed: ' + ', '.join(self.errors)