From 26a434639ad89f9b67826eff62f8f5cfe818c45c Mon Sep 17 00:00:00 2001 From: Bernhard Frauendienst Date: Sat, 7 Dec 2024 13:43:25 +0100 Subject: [PATCH] feat(conform-dom): support intent to validate a full fieldset --- packages/conform-dom/form.ts | 8 ++++++++ packages/conform-dom/submission.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/packages/conform-dom/form.ts b/packages/conform-dom/form.ts index 66717aa0..cb45fe05 100644 --- a/packages/conform-dom/form.ts +++ b/packages/conform-dom/form.ts @@ -332,6 +332,14 @@ function handleIntent( switch (intent.type) { case 'validate': { if (intent.payload.name) { + if (intent.payload.recursive) { + const allNames = Object.keys(meta.error).concat(fields ?? []); + for (const name of allNames) { + if (isPrefix(name, intent.payload.name)) { + meta.validated[name] = true; + } + } + } meta.validated[intent.payload.name] = true; } else { setFieldsValidated(meta, fields); diff --git a/packages/conform-dom/submission.ts b/packages/conform-dom/submission.ts index c13ec74b..21b28024 100644 --- a/packages/conform-dom/submission.ts +++ b/packages/conform-dom/submission.ts @@ -304,6 +304,7 @@ export type ValidateIntent = { type: 'validate'; payload: { name?: FieldName; + recursive?: boolean; }; };