formstand 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -221,12 +221,32 @@ var fieldSchemaForIntrospection = (schema, path) => {
221
221
  );
222
222
  };
223
223
  var containerKindAt = (schema) => (prefix) => {
224
- const sub = fieldSchemaForIntrospection(schema, prefix);
225
- if (sub === null) return null;
226
224
  const unwrapAll = (s) => {
227
225
  const inner2 = unwrapForWalk(s);
228
226
  return inner2 === null ? s : unwrapAll(inner2);
229
227
  };
228
+ const step = (s, segment) => {
229
+ const inner2 = unwrapAll(s);
230
+ if (inner2 instanceof z.ZodObject && typeof segment === "string") {
231
+ const shape = inner2.shape;
232
+ return Object.hasOwn(shape, segment) ? shape[segment] ?? null : null;
233
+ }
234
+ if (inner2 instanceof z.ZodArray && typeof segment === "number") {
235
+ return inner2.element;
236
+ }
237
+ if (inner2 instanceof z.ZodTuple && typeof segment === "number") {
238
+ return inner2.def.items[segment] ?? null;
239
+ }
240
+ if (inner2 instanceof z.ZodRecord) {
241
+ return inner2.valueType;
242
+ }
243
+ return null;
244
+ };
245
+ const sub = parsePath(prefix).reduce(
246
+ (current, segment) => current === null ? null : step(current, segment),
247
+ schema
248
+ );
249
+ if (sub === null) return null;
230
250
  const inner = unwrapAll(sub);
231
251
  if (inner instanceof z.ZodArray || inner instanceof z.ZodTuple) {
232
252
  return "array";