Skip to content

Commit b3447ab

Browse files
committed
fix(core): align formField.required with field.required for checkbox-group
1 parent ec92930 commit b3447ab

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@bigcommerce/catalyst-core": patch
3+
---
4+
5+
Fix `formField.required` mismatch for `checkbox-group` fields in `DynamicForm`. The schema branch was missing `.optional()` for non-required checkbox groups.
6+

core/vibes/soul/form/dynamic-form/schema.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,10 @@ function getFieldSchema(
298298
if (field.required !== true) fieldSchema = fieldSchema.optional();
299299

300300
break;
301-
301+
302302
case 'checkbox-group':
303-
fieldSchema = z.string().array();
304-
305-
if (field.required === true) fieldSchema = fieldSchema.nonempty();
303+
fieldSchema =
304+
field.required === true ? z.string().array().nonempty() : z.string().array().optional();
306305

307306
break;
308307

0 commit comments

Comments
 (0)