Skip to content

Commit 2f9e41f

Browse files
committed
feat: allow multiple fields to be validated in one intent
1 parent cb98494 commit 2f9e41f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/conform-dom/form.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,13 @@ function handleIntent<Error>(
332332
switch (intent.type) {
333333
case 'validate': {
334334
if (intent.payload.name) {
335-
meta.validated[intent.payload.name] = true;
335+
if (typeof intent.payload.name === 'string') {
336+
meta.validated[intent.payload.name] = true;
337+
} else {
338+
for (const name of intent.payload.name) {
339+
meta.validated[name] = true;
340+
}
341+
}
336342
} else {
337343
setFieldsValidated(meta, fields);
338344
}

packages/conform-dom/submission.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export function replySubmission<FormError>(
303303
export type ValidateIntent<Schema = any> = {
304304
type: 'validate';
305305
payload: {
306-
name?: FieldName<Schema>;
306+
name?: FieldName<Schema> | FieldName<Schema>[];
307307
};
308308
};
309309

0 commit comments

Comments
 (0)