Conversation
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
Adds a Zod-specific property override for C# types whose runtime validator is supplied by a frontend package or shared schema module.
[TsType]remains responsible for static TypeScript typing. The new[ZodSchema]attribute supplies the runtime Zod expression and optional named import:The same configuration is available fluently for referenced models:
Generated output:
Behavior
z.unknown()fallback.[ZodSchema("expression", ImportFrom = "module")]and both fluent overloads.z.string().startsWith('ord_').PatchField<T>modifiers after the override.z.compile(...), inferred types, generated guards, and TanStack payload validation.The documentation also explains that
z.toZod<T>()requires exact type equality. A schema merely assignable to a[TsType]type may not satisfy conformance. Forzod-geojson, its ownGeoJSONPointandGeoJSONFeatureinferred aliases support exact conformance.Closes #20.
Affected package(s)
Type of change
Examples and documentation
zod-geojson.[TsType]overrides from runtime[ZodSchema]validation.How was this verified?
dotnet test ... --filter "FullyQualifiedName!~CompilationTests"— 262 passed.zod@4.6.1,zod-geojson@1.7.1,@types/geojson, andtsccompilation.GeoJSONPointSchema/GeoJSONFeatureSchemaimports and usages.dotnet build ZibStack.NET.slnx --no-restore— succeeded with 0 errors and no new warnings.The Astro documentation build was attempted, but the existing local
docs/node_modulescontains files that Windows reports as access denied. No documentation-source error was reported before that environment failure.Checklist
master, focused on a single changedocs/src/content/docs/and the package README[Package]: …prefix