Skip to main content

domain/
customer.rs

1//! Customer identity and contact values used by reservation and messaging workflows.
2//!
3//! These newtypes promote portal/import strings into validated customer facts before they are
4//! used for labor-saving automation such as inbox drafting, reservation triage, and follow-up.
5//! They do not prove identity or consent by themselves; adapters must still attach provenance and
6//! any required approval gates before live customer communication.
7
8use nutype::nutype;
9#[allow(unused_imports)]
10use serde::{Deserialize, Serialize};
11
12/// Customer display name as staff, portal records, and customer-facing drafts should show it.
13///
14/// The value is trimmed and bounded so generated messages, manager briefings, and search indexes
15/// can carry a stable customer label without accepting blank source data.
16#[nutype(
17    sanitize(trim),
18    validate(not_empty, len_char_max = 120),
19    derive(
20        Debug,
21        Clone,
22        PartialEq,
23        Eq,
24        PartialOrd,
25        Ord,
26        Hash,
27        Serialize,
28        Deserialize
29    )
30)]
31pub struct Name(String);
32
33/// Customer email address captured from a portal, staff entry, import, or messaging boundary.
34///
35/// This type only enforces the storage/display envelope; workflows must still respect channel
36/// consent, approval state, and resort policy before sending outbound email.
37#[nutype(
38    sanitize(trim),
39    validate(not_empty, len_char_max = 254),
40    derive(
41        Debug,
42        Clone,
43        PartialEq,
44        Eq,
45        PartialOrd,
46        Ord,
47        Hash,
48        Serialize,
49        Deserialize
50    )
51)]
52pub struct Email(String);
53
54/// Customer phone number text used for call, SMS, and staff-note correlation.
55///
56/// The type preserves a normalized non-empty contact string for source-derived records; it is not
57/// a permission to text or call without the message-policy and review gates required upstream.
58#[nutype(
59    sanitize(trim),
60    validate(not_empty, len_char_max = 40),
61    derive(
62        Debug,
63        Clone,
64        PartialEq,
65        Eq,
66        PartialOrd,
67        Ord,
68        Hash,
69        Serialize,
70        Deserialize
71    )
72)]
73pub struct Phone(String);