Skip to content

docs: refresh examples with the new feature set - #25

Merged
cryo2010 merged 2 commits into
mainfrom
docs/example-refresh
Jul 24, 2026
Merged

cryo2010 merged 2 commits into
mainfrom
docs/example-refresh

Conversation

@cryo2010

Copy link
Copy Markdown
Owner

Summary

The examples were frozen at the pre-hardening feature set and demonstrated none of the additions since (custom messages, nullable, transform, sized numerics, literal, untagged unions, string formats, describe/title). This refresh weaves them in where they naturally fit.

examples/basic.nim: a custom issue message on a refinement (visible in the error walk), plus a closing tour section: slug/url formats, nullable vs optional side by side, a date transform producing a real Time, and toJsonSchema with title/describe.

examples/complex.nim: now also exercises literal("v1").default("v1") pinning, slug/semver/url formats (the custom refine demo moves onto the slug chain), a nullable homepage, custom messages, an untagged oneOfSchema accepting unix seconds or ISO datetime behind a created_at alias (union + transform + alias in one field), a uint16 container port whose range is enforced through the discriminated union, and a JSON Schema dump with metadata. The unhappy path now demonstrates the new issue shapes: must be "v1", no alternative matched with the closest branch's issues, and deploy.port: must be <= 65535 (16 issues total).

README: the Complex Example section mirrors the new schema and its documented 12-issue error output is byte-for-byte what the code produces (verified by compiling and running the assembled snippet with a payload); the deploy union snippet uses the sized uint16 port.

Verification

Both examples compile and run with the shown output; the README complex block, error output, and deploy snippet were assembled into standalone programs and executed; full test suite still passes (244 tests).

cryo2010 added 2 commits July 24, 2026 14:14
basic.nim gains a custom issue message and a tour section: string
formats, nullable vs optional, a transform producing a Time, and
toJsonSchema with title/describe metadata. complex.nim now exercises
literal + default pinning, slug/semver/url formats, a nullable field,
custom messages, an untagged union with a transform behind an alias, a
uint16 deploy port (range enforced through the variant), and ends with
JSON Schema output; its unhappy path shows the new issue shapes
(literal, union closest-branch, sized-int range).

The README complex example and its documented error output are updated
to match (both verified by compiling and running the assembled
snippet), and the deploy union snippet uses the sized port.
A new examples job runs every examples/*.nim with nim r, so the
README's runnable showcase can no longer drift from the API. The glob
auto-discovers future examples; running (not just compiling) also
catches runtime regressions.
@cryo2010
cryo2010 merged commit 56b91c7 into main Jul 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant