Skip to content

Extensible string generation and recursive custom mocks - #80

Merged
Saeris merged 2 commits into
mainfrom
feat/extensible-mocking
Nov 4, 2026
Merged

Saeris merged 2 commits into
mainfrom
feat/extensible-mocking

Conversation

@Saeris

@Saeris Saeris commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Summary

Changes needed so libraries such as @saeris/valicon can integrate with Valimock cleanly, plus the shared config migration that was pending locally.

  • stringActions / stringFormats options: handlers for foreign string actions, keyed by action type, and generators for the formats they name. Merged over the built-in registries, so they can also override built-in behavior. StringContext gains a custom scratch field for handler to generator hand-off.
  • customMocks entries receive a third argument, mock, bound to the same instance, so container overrides can recurse without a second Valimock.
  • walkPipe flattens nested pipes. Previously v.pipe(v.pipe(v.number(), v.integer()), v.maxValue(10)) produced floats because the inner integer action was never visited.
  • Faker is seeded once per top-level mock() instead of before every nested value. Seeded runs stay deterministic, and two sibling fields with the same schema no longer come out identical.
  • First commit: adopt @saeris/configs for lint, format and tsconfig.

Verification

  • vp check: no lint, format or type issues.
  • vp test: 233 tests, including new coverage for each change (stringExtensions.spec.ts, walkPipe.spec.ts, the recursion case in customMocks.spec.ts, and the sibling-field seed case in mockOptions.spec.ts).
  • vp pack builds.

Replace the inline Oxlint and Oxfmt configuration with the shared presets and reformat the codebase to match.
…pes and per-call seeding

Add stringActions and stringFormats options, merged over the built-in registries, so libraries that ship their own string actions can teach Valimock to generate matching values. Add a custom scratch field on StringContext for handlers to pass data to generators.

Pass the instance's mock function as the third argument of customMocks entries so container overrides can recurse without constructing a second Valimock.

Flatten nested pipes in walkPipe so constraints declared in an inner pipe are honored.

Seed Faker once per top-level mock() call rather than before every nested value, so sibling fields with the same schema no longer receive identical values while seeded runs stay deterministic.
@codesandbox

codesandbox Bot commented Nov 4, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web Editor • VS Code • Insiders

Open Preview

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

bumpy-frog

The changes in this PR will be included in the next version bump.

minor Minor releases

  • valimock 1.6.0 → 1.7.0

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

@Saeris
Saeris merged commit b6ec11f into main Nov 4, 2026
4 checks passed
@Saeris
Saeris deleted the feat/extensible-mocking branch November 4, 2026 21:07
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