Skip to main content

made_core/value_objects/
evidence_body.rs

1use serde::{Deserialize, Serialize};
2
3use crate::error::DomainError;
4
5/// Non-empty evidence excerpt made available to a support judge.
6#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
7#[serde(transparent)]
8pub struct EvidenceBody(String);
9
10impl EvidenceBody {
11    pub fn new(raw: impl Into<String>) -> Result<Self, DomainError> {
12        let raw = raw.into();
13        if raw.trim().is_empty() {
14            return Err(DomainError::EmptyField {
15                field: "evidence_support.body",
16            });
17        }
18        Ok(Self(raw))
19    }
20
21    #[must_use]
22    pub fn as_str(&self) -> &str {
23        &self.0
24    }
25}