Skip to content

Comments

fix: add nullable support and replace silent failures with explicit errors#109

Merged
ssilvius merged 2 commits intomainfrom
fix/error-handling-and-nullable
Feb 23, 2026
Merged

fix: add nullable support and replace silent failures with explicit errors#109
ssilvius merged 2 commits intomainfrom
fix/error-handling-and-nullable

Conversation

@ssilvius
Copy link
Contributor

Summary

  • Nullable/nullish support: z.nullable(), z.nullish(), and z.string().nullable().optional() now correctly unwrap and set isNullable on field descriptors. Previously these crashed or produced wrong output.
  • Fail-hard philosophy: Replaced 7 silent failure patterns with explicit throws. The code generator now fails loudly instead of silently producing partial/incorrect forms.
  • Unknown check warnings: Zod checks not recognized by the constraint extractor are surfaced as warnings instead of being silently ignored.

What changed

File Change
unwrap.ts Handle nullable wrappers, return isNullable flag
introspect.ts Exhaustive switch in buildMetadata, empty enum guard, unknown checks, description from outer wrapper
checks.ts Collect unknown Zod checks into warnings array
generator.ts Remove try-catch that silently dropped fields
form-wrapper.ts Throw on missing config instead of silent skip
field-components.ts Validate non-empty options for Select/RadioGroup
cli.ts Proper type narrowing, no silent default export fallback
types.ts Add isNullable to FieldDescriptor, warnings to FormDescriptor

Test plan

  • 242/242 tests passing (was 238 before nullable tests added)
  • 4 new nullable test cases in introspect.test.ts
  • Updated existing tests to match fail-hard behavior (generator, form-wrapper)
  • Biome lint clean
  • TypeScript typecheck passes

Generated with Claude Code

…rrors

Nullable/nullish schemas were silently dropped, producing incorrect forms.
Seven silent failure patterns replaced with explicit throws so the code
generator fails loudly instead of producing partial output.

Changes:
- unwrap.ts: handle nullable/nullish wrappers, return isNullable flag
- introspect.ts: exhaustive switch in buildMetadata, empty enum validation,
  unknown checks collection, description from outer wrapper
- checks.ts: collect unknown Zod checks as warnings
- generator.ts: remove try-catch that silently dropped fields
- form-wrapper.ts: throw on missing config instead of silent skip
- field-components.ts: validate non-empty options for Select/RadioGroup
- cli.ts: proper type narrowing, no silent default export fallback

242 tests passing (4 new nullable tests added).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The prior guard already throws if schema is falsy, making the !schema
condition always false at the later type validation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ssilvius ssilvius merged commit 9684877 into main Feb 23, 2026
2 checks passed
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