Skip to content
Skills Library
Programming · Building & coding

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.

Repository
Esposter ↗
Licence
Apache-2.0
Last repository change
26.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
4
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 26.10.2026, without references to retired models or APIs.

Licence

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

  1. normalizeString
  2. pluralize
  3. Convention: string not string | null
  4. When to use normalizeString
  5. When not to use normalizeString
  6. Zod Schema Alignment
  7. Matching a Token Inside Authored Content
  8. HTML Sanitization at the Zod Boundary
  9. Reference pages
Original SKILL.md headings · 65 lines, 440 words
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.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.