// common/proto/table_validation.proto syntax = "proto3"; package komp_ac.table_validation; // Request validation rules for a table message GetTableValidationRequest { string profileName = 1; string tableName = 2; } // Response with field-level validations; if a field is omitted, // no validation is applied (default unspecified). message TableValidationResponse { repeated FieldValidation fields = 1; } // Field-level validation (extensible for future kinds) message FieldValidation { // MUST match your frontend FormState.dataKey for the column string dataKey = 1; // Current: only CharacterLimits. More rules can be added later. CharacterLimits limits = 10; // Future expansion: PatternRules pattern = 11; // Validation 2 optional CustomFormatter formatter = 14; // Validation 4 – custom formatting logic DisplayMask mask = 3; // ExternalValidation external = 13; // CustomFormatter formatter = 14; bool required = 4; } // Character length counting mode enum CountMode { COUNT_MODE_UNSPECIFIED = 0; // default: same as CHARS CHARS = 1; BYTES = 2; DISPLAY_WIDTH = 3; } // Character limit validation (Validation 1) message CharacterLimits { // When zero, the field is considered "not set". If both min/max are zero, // the server should avoid sending this FieldValidation (no validation). uint32 min = 1; uint32 max = 2; // Optional warning threshold; when unset, no warning threshold is applied. optional uint32 warnAt = 3; CountMode countMode = 4; // defaults to CHARS if unspecified } // Mask for pretty display message DisplayMask { string pattern = 1; // e.g., "(###) ###-####" or "####-##-##" string input_char = 2; // e.g., "#" optional string template_char = 3; // e.g., "_" } // One position‑based validation rule, similar to CharacterFilter + PositionRange message PatternRule { // Range descriptor: how far the rule applies // Examples: // - "0" → Single position 0 // - "0-3" → Range 0..3 inclusive // - "from:5" → From position 5 onward // - "0,2,5" → Multiple discrete positions string range = 1; // Character filter type, case‑insensitive keywords: // "ALPHABETIC", "NUMERIC", "ALPHANUMERIC", // "ONEOF()", "EXACT(:)", "CUSTOM()" string filter = 2; } message CustomFormatter { // Formatter type identifier; handled client‑side. // Examples: "PSCFormatter", "PhoneFormatter", "CreditCardFormatter", "DateFormatter" string type = 1; // Optional free‑text note or parameters (e.g. locale, pattern) optional string description = 2; } // Collection of pattern rules for one field message PatternRules { // All rules that make up the validation logic repeated PatternRule rules = 1; // Optional human‑readable description for UI/debug purposes optional string description = 2; } // Service to fetch validations for a table service TableValidationService { rpc GetTableValidation(GetTableValidationRequest) returns (TableValidationResponse); rpc UpdateFieldValidation(UpdateFieldValidationRequest) returns (UpdateFieldValidationResponse); } message UpdateFieldValidationRequest { string profileName = 1; string tableName = 2; string dataKey = 3; FieldValidation validation = 4; } message UpdateFieldValidationResponse { bool success = 1; string message = 2; }