string-utils
/string-utils
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.
- Author
- Esposter ↗
- Repository
- Esposter ↗
- Licence
- Apache-2.0
- Last repository change
- 26.10.2026
Assessment and security
- Files in this package
- 4
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 26.10.2026, without references to retired models or APIs.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
What it does and when to use it
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.
Original author 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.
How it works
- 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
SKILL.md preview
---
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.
Files in this package (4)
- SKILL.md 3 KB
- references/content-tokens.md 2 KB
- references/html-sanitization.md 2 KB
- references/pluralize.md 1 KB
Versions
The database has no other skills named string-utils.
Database snapshot: 13.11.2026 · package version 587e51cf877d (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 90zod
Apply when writing Zod schemas. Esposter's Zod conventions for schema shape, boundary parsing and constraints. Schemas a schema form renders have extra rules — see the ui-library skill. - 95zod-patterns
Zod schema validation, type-safe development, and strict TypeScript patterns. When user works with Zod, validates data, creates schemas, handles form validation, mentions z.object/z.string patterns, needs runtime validation, type-safe code, or strict TypeScript configuration. - 100handle-errors
Apply codebase error handling patterns: Zod validation at boundaries, typed errors, early returns, and retry/backoff. Use when implementing error handling or input validation. - 100zod
Zod schema validation best practices for type safety, parsing, and error handling. This skill should be used when defining z.object schemas, using z.string validations, safeParse, or z.infer. This skill does NOT cover React Hook Form integration patterns (use react-hook-form… - 90xcode-localization-workflow
Plan, implement, review, and validate Apple-platform localization with Xcode String Catalogs. Use for .xcstrings setup, localizable SwiftUI and Foundation text, string tables, comments, plural and device variants, XLIFF handoff, locale UI checks, or Xcode 27 agent-assisted translation. - 90azure-table
Apply when reading or writing Azure Table Storage data (messages, moderation logs) in server code. Esposter's Azure Table Storage conventions, where the shared `@esposter/db` and `@esposter/azure` helpers own each table job and are never hand-rolled.