konduto/types/device/
provider.rs

1use crate::impl_nutype_error_conversion;
2use nutype::nutype;
3
4/// Provedor do dispositivo (mínimo 2, máximo 255 caracteres)
5///
6/// # Validações
7/// - Não pode ser vazio (após trim)
8/// - Mínimo 2 caracteres
9/// - Máximo 255 caracteres
10///
11/// # Exemplos
12/// ```
13/// use konduto::provider::DeviceProvider;
14///
15/// let provider = DeviceProvider::try_new("Vivo").unwrap();
16/// assert_eq!(provider.as_str(), "Vivo");
17/// ```
18#[nutype(
19    sanitize(trim),
20    validate(not_empty, len_char_min = 2, len_char_max = 255),
21    derive(
22        Debug,
23        Clone,
24        PartialEq,
25        Eq,
26        Display,
27        AsRef,
28        Deref,
29        Serialize,
30        Deserialize,
31    )
32)]
33pub struct DeviceProvider(String);
34
35impl DeviceProvider {
36    /// Retorna o provedor como string slice (compatibilidade)
37    pub fn as_str(&self) -> &str {
38        self.as_ref()
39    }
40}
41
42impl_nutype_error_conversion!(DeviceProviderError);