Repository navigation
docs: refresh examples with the new feature set - #25
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/urlformats,nullablevsoptionalside by side, adatetransform producing a realTime, andtoJsonSchemawithtitle/describe.examples/complex.nim: now also exercises
literal("v1").default("v1")pinning,slug/semver/urlformats (the customrefinedemo moves onto the slug chain), anullablehomepage, custom messages, an untaggedoneOfSchemaaccepting unix seconds or ISO datetime behind acreated_atalias (union + transform + alias in one field), auint16container 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 matchedwith the closest branch's issues, anddeploy.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
uint16port.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).