string-utils
/string-utils
Stosuje zasady obsługi stringów w kodzie Esposter: przycinanie, normalizacja, sanityzacja, liczba mnoga i dopasowanie tokenów w treściach, na granicach Zod i w tekście rich text.
- Autor
- Esposter ↗
- Repozytorium
- Esposter ↗
- Licencja
- Apache-2.0
- Ostatnia zmiana repozytorium
- 26.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 4
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 26.10.2026, bez odwołań do wycofanych modeli i API.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
Co robi i kiedy
Stosuje zasady obsługi stringów w kodzie Esposter: przycinanie, normalizacja, sanityzacja, liczba mnoga i dopasowanie tokenów w treściach, na granicach Zod i w tekście rich text.
Oryginalny opis (EN)
Apply when trimming, normalizing or sanitizing a string, pluralizing a count, or matching a token inside authored content. Esposter's string handling for app code, Zod boundaries and authored rich text.
Jak działa
- normalizeString
- pluralize
- Convention: string not string | null
- When to use normalizeString
- When not to use normalizeString
- Zod Schema Alignment
- Matching a Token Inside Authored Content
- HTML Sanitization at the Zod Boundary
- Reference pages
Podgląd SKILL.md
---
name: string-utils
description: Apply when trimming, normalizing or sanitizing a string, pluralizing a count, or matching a token inside authored content. Esposter's string handling for app code, Zod boundaries and authored rich text.
---
# String Normalization
## `normalizeString`
Trims whitespace and returns empty string for an absent (`undefined`) input. Lives in `@esposter/shared`.
```ts
import { normalizeString } from "@esposter/shared";
normalizeString(" hello "); // → "hello"
normalizeString(undefined); // → ""
```
## `pluralize`
`${count} ${pluralize("result", count)}` — the hand-rolled `""`/`"s"` ternary is a `no-restricted-syntax` error, and a non-plural `s` disables it with that reason (`references/pluralize.md`).
## Convention: `string` not `string | null`
Optional text is `string` with `""` as its absence — the `absent-values` skill (`references/string-sentinel.md`, and `references/sentinel-columns.md` for the column side).
## When to use `normalizeString`
The default trim in app code — reach for it over a bare `.trim()`:
- Parsing (CSV, XLSX, clipboard): `normalizeString(cell?.toString())`
- Array mapping: `values.map(normalizeString).filter(Boolean)`
- Guard checks: `if (!normalizeString(value)) return;`
- Filter predicates: `.filter((line) => normalizeString(line) !== "")`
- Zod schemas: "Zod Schema Alignment" on this page
## When not to use `normalizeString`
- **Never in Vue** — lint-enforced by `restrictedTrimSyntaxes.js`; the `vue` skill owns the why (`references/forms.md`).
- **User-facing transformation actions** — e.g. `computeStringTransformation.ts` `Trim` case; keep `value.trim()`, it's implementing a named user operation.
- **Trimming a process's or a file's output inside a package** — stdout, a token file, a hook's stdin, an XML reader's own `trim` option. `.trim()` is correct there: none of it is user input crossing a Zod boundary, and a package that has no other use for `@esposter/shared` should not take it on for a trim.
`.trimStart()` and `.trimEnd()` are separate methods — replace only when semantically equivalent to a full `.trim()`.
## Zod Schema Alignment
Base select schemas normalize so server validation matches client input. Always transform first, then validators in the pipe. Never add trim transforms to derived schemas (`UpdateFooInput`, etc.) — only in the base select schema.
Prefer the shared schema helpers over hand-rolling the transform+pipe — the `zod` skill (`references/string-normalization.md`).
```ts
// db-schema createSelectSchema overrides — the canonical form
foo: (schema) => createNormalizedStringSchema(FOO_MAX_LENGTH, schema),
```
## Matching a Token Inside Authored Content
A token in authored content is matched on the delimiter that opened it, over the parsed value's string leaves, in one pass keyed by a `Map`, and a changed form widens the reader rather than backfilling (`references/content-tokens.md`, `openspec/specs/architecture/content-token-rewriting/design.md`).
## HTML Sanitization at the Zod Boundary
Rich-text HTML is sanitized once, by `.transform(sanitizeTextHtml)` in the base Zod schema — never a frontend call, except a localStorage draft (`references/html-sanitization.md`).
## Reference pages
- `references/pluralize.md` — when a string carries a count, or the plural ternary is refused.
- `references/content-tokens.md` — before writing or widening a regex over authored content.
- `references/html-sanitization.md` — when a field holds rich-text HTML, or a sanitize call is about to be written.
Pliki w paczce (4)
- SKILL.md 3 KB
- references/content-tokens.md 2 KB
- references/html-sanitization.md 2 KB
- references/pluralize.md 1 KB
Wersje
W bazie nie ma innych skilli o nazwie string-utils.
Migawka bazy z 13.11.2026 · wersja paczki 587e51cf877d (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 90zod
Stosuje konwencje projektu Esposter przy pisaniu schematów Zod: kształt schematu, parsowanie na granicach systemu i ograniczenia wartości. - 95zod-patterns
Wspiera walidację schematów w Zod i ścisłe wzorce TypeScript: schematy, walidację formularzy, z.object i z.string oraz konfigurację strict. - 100handle-errors
Stosuje wzorce obsługi błędów w bazie kodu: walidację Zod na granicach, typowane błędy, wczesne zwroty oraz retry z backoffem. - 100zod
Podaje dobre praktyki Zod dla bezpieczeństwa typów, parsowania i obsługi błędów: schematy z.object, walidacje z.string, safeParse i z.infer. - 90xcode-localization-workflow
Planuje, wdraża i waliduje lokalizację na platformach Apple z Xcode String Catalogs: .xcstrings, tabele stringów, liczba mnoga i warianty urządzeń, przekazanie XLIFF. - 90azure-table
Opisuje konwencje Esposter dla odczytu i zapisu danych w Azure Table Storage (wiadomości, logi moderacji) z użyciem wspólnych helperów @esposter/db i @esposter/azure.