Conversation
add ash_valibot.ts to gitignore add mix alias "test.test_valibot"
chore format
|
Thanks for the contribution! Valibot support is a reasonable feature request. A few notes before this can move forward: Code duplicationThe main concern is that Rather than maintaining two ~780-line generators in parallel, this should extract the shared logic and parameterize the output format. For example: # Shared behaviour that both generators implement
defmodule AshTypescript.Codegen.SchemaFormatter do
@callback format_string(constraints :: keyword()) :: String.t()
@callback format_integer(constraints :: keyword()) :: String.t()
@callback format_object(fields :: list()) :: String.t()
@callback format_optional(inner :: String.t()) :: String.t()
@callback format_array(inner :: String.t()) :: String.t()
@callback format_enum(values :: list()) :: String.t()
# ... etc
endThen the core generator handles field discovery, topological sort, action introspection, etc. once — and delegates formatting to the appropriate implementation. The Zod and Valibot modules become thin ~100-line adapters. API correctness
Doc copy-paste
TestsSeveral exported test functions in |
Introduces two new modules to eliminate the ~780-line duplication between ZodSchemaGenerator and ValibotSchemaGenerator: - SchemaFormatter: behaviour defining ~20 output-syntax callbacks (wrap_optional, wrap_array, format_enum, format_string, etc.) - SchemaCore: all shared logic delegating output to a formatter module (topological sort, dep discovery, field/action introspection, resource schema generation, regex safety helpers)
…tter adapters Both generators now implement SchemaFormatter and delegate all shared logic to SchemaCore, reducing each from ~780 lines to ~175 lines. Also fixes a Valibot API correctness bug: non-empty required strings now emit v.pipe(v.string(), v.minLength(1)) instead of the invalid v.string().min(1) (Valibot does not support method chaining).
… runners - Add valibot_constraints_test.exs mirroring ZodConstraintsTest with Valibot-specific assertions (v.pipe composition, v.optional wrapping, v.picklist enums, no method chaining) - Wire up 28 previously exported-but-uncalled functions in runValibotTests.ts (regex, float, CiString, optional, boundary tests)
|
Refactoring looks good! The SchemaFormatter behaviour + SchemaCore extraction is clean. Two remaining items:
But the actual schema constant uses the configured |
Contributor checklist
Leave anything that you believe does not apply unchecked.