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

View File

@@ -13,7 +13,7 @@ package komp_ac.table_validation;
//
// Important split:
// - limits / pattern / allowed_values / required are validation rules.
// - mask is presentation and input-shaping metadata for clients.
// - mask is presentation/input-shaping metadata plus an optional storage policy.
// Request validation rules for a table
message GetTableValidationRequest {
@@ -44,7 +44,7 @@ message FieldValidation {
// Client-side hint that this field participates in external/asynchronous validation UI.
bool external_validation_enabled = 13;
// Client-side display mask metadata. The server stores raw data without mask literals.
// Client-side display mask metadata and persisted representation policy.
DisplayMask mask = 3;
// Field must be provided / treated as required by clients and server enforcement layers.
@@ -76,14 +76,18 @@ message CharacterLimits {
CountMode countMode = 4; // defaults to CHARS if unspecified
}
// 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.
enum MaskStorageMode {
MASK_STORAGE_MODE_RAW = 0;
MASK_STORAGE_MODE_FORMATTED = 1;
}
// Mask metadata used for rendering, input navigation, and optional persistence
// of reached mask literals. Template placeholders are never persisted.
message DisplayMask {
string pattern = 1; // e.g., "(###) ###-####" or "####-##-##"
string input_char = 2; // e.g., "#"
optional string template_char = 3; // e.g., "_"
optional MaskStorageMode storage_mode = 4; // absent/default means raw
}
// Which positions a pattern rule applies to.

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)]