fromWire static method
Implementation
static ZorphyBoundaryResult<AgentMessage> fromWire(Map<String, Object?> raw) {
final violations = <FieldViolation>[];
final Object? raw_role = raw['role'];
AgentMessageRole? _role;
_role = ZorphyPatchWire.enumByName<AgentMessageRole>(
AgentMessageRole.values,
raw_role,
'/role',
violations,
);
final Object? raw_text = raw['text'];
String? _text;
_text = _boundaryAs<String>(raw_text, '/text', violations);
final Object? raw_turn = raw['turn'];
int? _turn;
_turn = _boundaryAs<int>(raw_turn, '/turn', violations);
if (violations.isNotEmpty) {
return BoundaryErr<AgentMessage>(
targetType: 'AgentMessage',
violations: violations,
);
}
return BoundaryOk<AgentMessage>(
AgentMessage.fromTrusted(role: _role!, text: _text!, turn: _turn!),
);
}