Skip to content

Commit 7bee85a

Browse files
Bill Leoutsakoswaleedlatif1
authored andcommitted
fix(copilot): reject empty required multi-selects
1 parent 593d9db commit 7bee85a

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎apps/sim/lib/workflows/editing/validation.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ describe('validateInputsForBlock', () => {
309309
id: 'eventTypes',
310310
type: 'dropdown' as const,
311311
multiSelect: true,
312+
required: true,
312313
options: [
313314
{ id: 'created', label: 'Created' },
314315
{ id: 'updated', label: 'Updated' },
@@ -332,6 +333,9 @@ describe('validateInputsForBlock', () => {
332333
'quickbooks-1'
333334
).valid
334335
).toBe(false)
336+
expect(
337+
validateValueForSubBlockType(config, [], 'eventTypes', 'quickbooks', 'quickbooks-1').valid
338+
).toBe(false)
335339
})
336340

337341
it('accepts condition-input arrays with arbitrary item ids', () => {

‎apps/sim/lib/workflows/editing/validation.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,9 @@ export function validateValueForSubBlockType(
391391
if (options && Array.isArray(options)) {
392392
const validIds = options.map((opt) => opt.id)
393393
const values = subBlockConfig.multiSelect && Array.isArray(value) ? value : [value]
394-
if (values.some((item) => !validIds.includes(item))) {
394+
const isEmptyRequiredMultiSelect =
395+
subBlockConfig.multiSelect && subBlockConfig.required && values.length === 0
396+
if (isEmptyRequiredMultiSelect || values.some((item) => !validIds.includes(item))) {
395397
return {
396398
valid: false,
397399
error: {

0 commit comments

Comments
 (0)