mask optionally part of the data

This commit is contained in:
Priec
2026-08-08 22:42:32 +02:00
parent d063ea3ffe
commit 9ea03e0cc9
8 changed files with 47 additions and 15 deletions

Binary file not shown.

View File

@@ -34,7 +34,7 @@ pub struct FieldValidation {
/// Client-side hint that this field participates in external/asynchronous validation UI.
#[prost(bool, tag = "13")]
pub external_validation_enabled: bool,
/// Client-side display mask metadata. The server stores raw data without mask literals.
/// Client-side display mask metadata and persisted representation policy.
#[prost(message, optional, tag = "3")]
pub mask: ::core::option::Option<DisplayMask>,
/// Field must be provided / treated as required by clients and server enforcement layers.
@@ -63,10 +63,8 @@ pub struct CharacterLimits {
#[prost(enumeration = "CountMode", tag = "4")]
pub count_mode: i32,
}
/// Mask for pretty display only.
///
/// This is not a validation rule by itself. It exists so clients can render and
/// navigate masked input while still storing raw values server-side.
/// Mask metadata used for rendering, input navigation, and optional persistence
/// of reached mask literals. Template placeholders are never persisted.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DisplayMask {
@@ -79,6 +77,9 @@ pub struct DisplayMask {
/// e.g., "\_"
#[prost(string, optional, tag = "3")]
pub template_char: ::core::option::Option<::prost::alloc::string::String>,
/// absent/default means raw
#[prost(enumeration = "MaskStorageMode", optional, tag = "4")]
pub storage_mode: ::core::option::Option<i32>,
}
/// Which positions a pattern rule applies to.
/// This exists instead of a string syntax like "0-3" so the server can validate
@@ -401,6 +402,32 @@ impl CountMode {
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum MaskStorageMode {
Raw = 0,
Formatted = 1,
}
impl MaskStorageMode {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Raw => "MASK_STORAGE_MODE_RAW",
Self::Formatted => "MASK_STORAGE_MODE_FORMATTED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"MASK_STORAGE_MODE_RAW" => Some(Self::Raw),
"MASK_STORAGE_MODE_FORMATTED" => Some(Self::Formatted),
_ => None,
}
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]