Documentation
¶
Index ¶
- Variables
- type StringRules
- func (*StringRules) Descriptor() ([]byte, []int)deprecated
- func (x *StringRules) GetCollapseSpaces() bool
- func (x *StringRules) GetLowercase() bool
- func (x *StringRules) GetNfc() bool
- func (x *StringRules) GetNullifyEmpty() bool
- func (x *StringRules) GetStripControl() bool
- func (x *StringRules) GetTrim() bool
- func (x *StringRules) GetUppercase() bool
- func (*StringRules) ProtoMessage()
- func (x *StringRules) ProtoReflect() protoreflect.Message
- func (x *StringRules) Reset()
- func (x *StringRules) String() string
Constants ¶
This section is empty.
Variables ¶
View Source
var (
// optional platform.strings.v1.StringRules string_rules = 50002;
E_StringRules = &file_platform_strings_v1_strings_proto_extTypes[0]
)
Extension fields to descriptorpb.FieldOptions.
View Source
var File_platform_strings_v1_strings_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type StringRules ¶
type StringRules struct {
// strings.TrimSpace — removes leading and trailing whitespace.
Trim bool `protobuf:"varint,1,opt,name=trim,proto3" json:"trim,omitempty"`
// Collapse internal runs of whitespace to a single ASCII space.
// Does not trim leading or trailing whitespace — combine with `trim` for that.
CollapseSpaces bool `protobuf:"varint,2,opt,name=collapse_spaces,json=collapseSpaces,proto3" json:"collapse_spaces,omitempty"`
// strings.ToLower — applied after trim and collapse_spaces.
// Mutually exclusive with `uppercase` (if both set, lowercase wins).
Lowercase bool `protobuf:"varint,3,opt,name=lowercase,proto3" json:"lowercase,omitempty"`
// strings.ToUpper — applied after trim and collapse_spaces.
Uppercase bool `protobuf:"varint,4,opt,name=uppercase,proto3" json:"uppercase,omitempty"`
// Unicode NFC normalization — canonical composition.
// Protects against visually identical but byte-different inputs
// (e.g. "é" as one code point vs e + combining acute).
Nfc bool `protobuf:"varint,5,opt,name=nfc,proto3" json:"nfc,omitempty"`
// Remove C0 controls (\x00-\x1F, except \t \n \r), zero-width spaces, BOM.
// Defensive against paste artefacts and basic unicode attacks.
StripControl bool `protobuf:"varint,6,opt,name=strip_control,json=stripControl,proto3" json:"strip_control,omitempty"`
// If the string is empty after all other rules, clear the field entirely.
// Only effective on proto3 optional fields — for non-optional fields the
// field stays set to "".
NullifyEmpty bool `protobuf:"varint,7,opt,name=nullify_empty,json=nullifyEmpty,proto3" json:"nullify_empty,omitempty"`
// contains filtered or unexported fields
}
StringRules — opt-in sanitization rules applied to a string field on the request side, before authentication / idempotency / validation.
Order of application is fixed and independent of field order in the message:
- strip_control — remove \x00-\x1F (except \t \n \r), zero-width, BOM
- nfc — Unicode NFC normalization
- trim — TrimSpace (leading and trailing)
- collapse_spaces — collapse runs of whitespace to a single ASCII space
- lowercase OR uppercase
- nullify_empty — if the result is "" after the above, clear the field (only effective on proto3 optional fields)
Fields without this annotation are left untouched. Passwords and secrets simply do not carry the annotation — there is no blocklist.
Example — Update profile:
message UpdateProfileRequest {
string name = 1 [(platform.strings.v1.string_rules) = {
trim: true, collapse_spaces: true, nfc: true
}];
string email = 2 [(platform.strings.v1.string_rules) = {
trim: true, lowercase: true
}];
string password = 3; // intentionally untouched
}
func (*StringRules) Descriptor
deprecated
func (*StringRules) Descriptor() ([]byte, []int)
Deprecated: Use StringRules.ProtoReflect.Descriptor instead.
func (*StringRules) GetCollapseSpaces ¶
func (x *StringRules) GetCollapseSpaces() bool
func (*StringRules) GetLowercase ¶
func (x *StringRules) GetLowercase() bool
func (*StringRules) GetNfc ¶
func (x *StringRules) GetNfc() bool
func (*StringRules) GetNullifyEmpty ¶
func (x *StringRules) GetNullifyEmpty() bool
func (*StringRules) GetStripControl ¶
func (x *StringRules) GetStripControl() bool
func (*StringRules) GetTrim ¶
func (x *StringRules) GetTrim() bool
func (*StringRules) GetUppercase ¶
func (x *StringRules) GetUppercase() bool
func (*StringRules) ProtoMessage ¶
func (*StringRules) ProtoMessage()
func (*StringRules) ProtoReflect ¶
func (x *StringRules) ProtoReflect() protoreflect.Message
func (*StringRules) Reset ¶
func (x *StringRules) Reset()
func (*StringRules) String ¶
func (x *StringRules) String() string
Click to show internal directories.
Click to hide internal directories.