Documentation
¶
Overview ¶
Package stringsx applies opt-in string sanitization rules declared via the (platform.strings.v1.string_rules) field option, ported from taply's strutil package.
Apply walks a request message, finds string fields annotated with string_rules, and applies the configured transformations in a fixed order:
- 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 — clear the field when the result is "" (proto3 optional only)
It must run BEFORE idempotency and validation, so that:
- the idempotency fingerprint is computed on the canonical form (so "Burger" and "Burger " produce the same hash),
- protovalidate rules like min_len see the trimmed value (so whitespace-only input fails validation as expected).
The api module does this when it is given the function: api.Normalize(app, stringsx.Apply).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Proto string
Proto is the source of the string_rules option: a project that annotates its fields needs it next to its own proto files as platform/strings/v1/strings.proto, so the descriptors of both are the same file.
Functions ¶
Types ¶
This section is empty.