Skip to content

Commit

Permalink
feat(conform-dom): support intent to validate a full fieldset
Browse files Browse the repository at this point in the history
  • Loading branch information
oxc committed Dec 7, 2024
1 parent cb98494 commit 26a4346
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/conform-dom/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ function handleIntent<Error>(
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);
Expand Down
1 change: 1 addition & 0 deletions packages/conform-dom/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ export type ValidateIntent<Schema = any> = {
type: 'validate';
payload: {
name?: FieldName<Schema>;
recursive?: boolean;
};
};

Expand Down

0 comments on commit 26a4346

Please sign in to comment.