TanStackT
TanStack2mo ago
15 replies
developed-pink

Accessing validation schema within a field context

Is there a way of accessing the validation schema for a given form field within a field context (e.g. when creating a composed form)?

By looking through the API reference I'm guessing this might not currently be possible. Honestly I'm not sure if Standard Schema directly would enable good ergonomics for achieving this even. But I'm still curious to know if this is a planned feature or if others have ways of achieving this.

Why would anyone want to do this?
Currently we're able to bind event handlers within form components using the field context, simplifying the "consumer"-side code, but we're still left to specify attributes such as required or maxLength manually on a per-field basis which effectively results in duplicating our schema to some extent, leaving us with two places to maintain this. Why not enable us to relying on one source of truth -- the schema?

I believe having this would encourage us to include additional metadata our schemas and enable us to create really versatile field components.

---

(Let me know if you'd prefer to move this to a GitHub issue/feature request/discussion)
Was this page helpful?