Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .changeset/pink-zoos-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
"@bigcommerce/catalyst-core": patch
---

Add missing check for optional text field in `core/vibes/soul/form/dynamic-form/schema.ts`.

## Migration

Add `if (field.required !== true) fieldSchema = fieldSchema.optional();` to `text` case in `core/vibes/soul/form/dynamic-form/schema.ts`:

```typescript
case 'text':
fieldSchema = z.string();

if (field.pattern != null) {
fieldSchema = fieldSchema.regex(new RegExp(field.pattern), {
message: 'Invalid format.',
});
}

if (field.required !== true) fieldSchema = fieldSchema.optional();

break;
```
2 changes: 2 additions & 0 deletions core/vibes/soul/form/dynamic-form/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ function getFieldSchema(field: Field) {
});
}

if (field.required !== true) fieldSchema = fieldSchema.optional();

break;

case 'password':
Expand Down