Repository navigation
Extensible string generation and recursive custom mocks - #80
Merged
Merged
Conversation
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.
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
Contributor
|
The changes in this PR will be included in the next version bump.
|
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
Changes needed so libraries such as
@saeris/valiconcan integrate with Valimock cleanly, plus the shared config migration that was pending locally.stringActions/stringFormatsoptions: handlers for foreign string actions, keyed by actiontype, and generators for the formats they name. Merged over the built-in registries, so they can also override built-in behavior.StringContextgains acustomscratch field for handler to generator hand-off.customMocksentries receive a third argument,mock, bound to the same instance, so container overrides can recurse without a secondValimock.walkPipeflattens nested pipes. Previouslyv.pipe(v.pipe(v.number(), v.integer()), v.maxValue(10))produced floats because the innerintegeraction was never visited.mock()instead of before every nested value. Seeded runs stay deterministic, and two sibling fields with the same schema no longer come out identical.@saeris/configsfor 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 incustomMocks.spec.ts, and the sibling-field seed case inmockOptions.spec.ts).vp packbuilds.