Skip to content

Commit 2b67846

Browse files
CopilotStarefossen
andauthored
fix: remove capacity requirement from user-facing workshop proposal schema (#356)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Starefossen <968267+Starefossen@users.noreply.github.com>
1 parent d1bc553 commit 2b67846

4 files changed

Lines changed: 6 additions & 71 deletions

File tree

__tests__/lib/proposal/schemas.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,19 @@ describe('ProposalInputSchema (strict)', () => {
121121
expect(result.success).toBe(false)
122122
})
123123

124-
it('requires capacity for workshop formats', () => {
124+
it('accepts workshop format with capacity', () => {
125125
const result = ProposalInputSchema.safeParse({
126126
...fullProposal,
127127
format: Format.workshop_120,
128+
capacity: 30,
128129
})
129-
expect(result.success).toBe(false)
130+
expect(result.success).toBe(true)
130131
})
131132

132-
it('accepts workshop format with capacity', () => {
133+
it('accepts workshop format without capacity', () => {
133134
const result = ProposalInputSchema.safeParse({
134135
...fullProposal,
135136
format: Format.workshop_120,
136-
capacity: 30,
137137
})
138138
expect(result.success).toBe(true)
139139
})

__tests__/lib/proposal/validation.test.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -103,42 +103,6 @@ describe('validateProposalForm', () => {
103103
expect(errors.tos).toBe(PROPOSAL_VALIDATION_MESSAGES.TOS_REQUIRED)
104104
})
105105

106-
it('returns capacity error for workshop_120 without capacity', () => {
107-
const errors = validateProposalForm(
108-
makeValidProposal({ format: Format.workshop_120 }),
109-
)
110-
expect(errors.capacity).toBe(PROPOSAL_VALIDATION_MESSAGES.CAPACITY_REQUIRED)
111-
})
112-
113-
it('returns capacity error for workshop_240 without capacity', () => {
114-
const errors = validateProposalForm(
115-
makeValidProposal({ format: Format.workshop_240 }),
116-
)
117-
expect(errors.capacity).toBe(PROPOSAL_VALIDATION_MESSAGES.CAPACITY_REQUIRED)
118-
})
119-
120-
it('accepts workshop format with capacity', () => {
121-
const errors = validateProposalForm(
122-
makeValidProposal({ format: Format.workshop_120, capacity: 30 }),
123-
)
124-
expect(errors.capacity).toBeUndefined()
125-
})
126-
127-
it('does not return capacity error for non-workshop formats', () => {
128-
const errors = validateProposalForm(
129-
makeValidProposal({ format: Format.presentation_40 }),
130-
)
131-
expect(errors.capacity).toBeUndefined()
132-
})
133-
134-
it('suppresses capacity check when requireCapacity is false', () => {
135-
const errors = validateProposalForm(
136-
makeValidProposal({ format: Format.workshop_120 }),
137-
{ requireCapacity: false },
138-
)
139-
expect(errors.capacity).toBeUndefined()
140-
})
141-
142106
it('returns multiple errors simultaneously', () => {
143107
const errors = validateProposalForm(
144108
makeValidProposal({

src/lib/proposal/validation.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ProposalInput, isWorkshopFormat } from './types'
1+
import { ProposalInput } from './types'
22

33
export const PROPOSAL_VALIDATION_MESSAGES = {
44
TITLE_REQUIRED: 'Title is required',
@@ -9,20 +9,12 @@ export const PROPOSAL_VALIDATION_MESSAGES = {
99
TOPICS_REQUIRED: 'At least one topic is required',
1010
SPEAKERS_REQUIRED: 'At least one speaker is required',
1111
TOS_REQUIRED: 'You must accept the terms of service',
12-
CAPACITY_REQUIRED: 'Workshop capacity is required for workshop formats',
1312
} as const
1413

15-
export interface ProposalValidationOptions {
16-
requireSpeakers?: boolean
17-
requireCapacity?: boolean
18-
}
19-
2014
export function validateProposalForm(
2115
proposal: ProposalInput,
22-
options: ProposalValidationOptions = {},
2316
): Record<string, string> {
2417
const errors: Record<string, string> = {}
25-
const { requireCapacity = true } = options
2618

2719
if (!proposal.title || proposal.title.trim() === '') {
2820
errors.title = PROPOSAL_VALIDATION_MESSAGES.TITLE_REQUIRED
@@ -52,23 +44,14 @@ export function validateProposalForm(
5244
errors.tos = PROPOSAL_VALIDATION_MESSAGES.TOS_REQUIRED
5345
}
5446

55-
// Workshop-specific validation
56-
if (
57-
requireCapacity &&
58-
isWorkshopFormat(proposal.format) &&
59-
!proposal.capacity
60-
) {
61-
errors.capacity = PROPOSAL_VALIDATION_MESSAGES.CAPACITY_REQUIRED
62-
}
63-
6447
return errors
6548
}
6649

6750
export function validateProposalForAdmin(
6851
proposal: ProposalInput,
6952
speakerIds: string[],
7053
): Record<string, string> {
71-
const errors = validateProposalForm(proposal, { requireSpeakers: true })
54+
const errors = validateProposalForm(proposal)
7255

7356
if (!speakerIds || speakerIds.length === 0) {
7457
errors.speakers = PROPOSAL_VALIDATION_MESSAGES.SPEAKERS_REQUIRED

src/server/schemas/proposal.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,6 @@ const ProposalInputBaseSchema = z.object({
6969

7070
// Proposal input schema (for create/update)
7171
export const ProposalInputSchema = ProposalInputBaseSchema.refine(
72-
(data) => {
73-
// Workshop formats require capacity
74-
if (isWorkshopFormat(data.format) && !data.capacity) {
75-
return false
76-
}
77-
return true
78-
},
79-
{
80-
message: 'Workshop capacity is required for workshop formats',
81-
path: ['capacity'],
82-
},
83-
).refine(
8472
(data) => {
8573
// Prerequisites should only be provided for workshop formats
8674
if (data.prerequisites && !isWorkshopFormat(data.format)) {

0 commit comments

Comments
 (0)