Enforce Submission Requirements (requireGithub, requireDemoVideo, etc.)
Objective
Dynamically adjust the SubmissionForm validation rules based on the hackathon's specific submission configuration. Required fields must be enforced at both the schema level and the UI level — validation must be conditional and data-driven, not hardcoded. Users should always have a clear, upfront visual signal that a field is required before they attempt to submit.
Technical Implementation
Target File
components/hackathons/submissions/SubmissionForm.tsx
Hook
- Use
useHackathonData() from @/lib/providers/hackathonProvider to access currentHackathon submission settings
- All boolean requirement flags (
requireGithub, requireDemoVideo, etc.) must be read directly from the hackathon context — never hardcoded or assumed
Logic Mapping
Schema Validation — submissionSchema (Zod)
- Modify
submissionSchema to conditionally enforce required fields based on the hackathon's requirement flags
- If
requireGithub is true, the schema must treat the absence of a GitHub link in the links array as a validation failure — the error should be surfaced at the links field level, not as a generic form error
- If
requireDemoVideo is true, the schema must enforce that videoUrl is a non-empty, valid URL
- Where Zod's static schema cannot cleanly express the conditional logic (e.g., checking for a specific link type within an array), inject validation errors manually using
form.setError() in the appropriate step handler rather than contorting the schema
- The validation approach — schema-level vs. manual injection — should be chosen based on what produces the cleanest, most maintainable code for each field
Step Validation — handleNext (Step 2)
- In
handleNext at Step 2, before allowing progression, explicitly check currentHackathon.requireGithub
- If
true and no GitHub link is present in form.watch('links'), block progression and inject a clear, field-level validation error directing the user to add their GitHub repository link
- Apply the same pattern for any other
require* flags that gate step progression
Form Submission — onSubmit
- Perform a final validation pass in
onSubmit that re-checks all require* flags against the current form values before the submission payload is constructed and dispatched
- This acts as the last line of defense — if a user somehow bypasses step-level validation,
onSubmit must catch it before any API call is made
- Validation errors caught at this stage must be surfaced as field-level errors, not silent failures
UI — Required Field Indicators
- Dynamically append an asterisk (
*) to the label of any FormField whose corresponding require* flag is true
- Affected fields include at minimum:
videoUrl (when requireDemoVideo is true) and the GitHub entry in the links section (when requireGithub is true)
- The
* must be driven by the flag values from useHackathonData() — it must not be hardcoded on the label
- Include a brief legend or helper text near the form (e.g.,
"* Required for this hackathon") so users understand what the asterisk means without ambiguity
- Required field indicators must be visible before the user attempts to submit — they are a proactive signal, not a post-submission error state
⚠️ Caution
This is a production environment — not a sandbox.
- Code must be performant, accessible, and clean
- No dummy data — all
require* flags must be sourced from useHackathonData(); never hardcode which fields are required
- AI-generated code will be scrutinized; poorly structured or "hallucinated" code will result in immediate issue closure
- Follow the existing design system: shadcn/ui, Tailwind, Framer Motion
- Strictly no
any types in schema definitions or validation logic
Testing & Verification
Automated Tests
npm run lint # Ensure code quality
npm run build # Verify no breaking changes in routing or types
Manual Verification
Enforce Submission Requirements (
requireGithub,requireDemoVideo, etc.)Objective
Dynamically adjust the
SubmissionFormvalidation rules based on the hackathon's specific submission configuration. Required fields must be enforced at both the schema level and the UI level — validation must be conditional and data-driven, not hardcoded. Users should always have a clear, upfront visual signal that a field is required before they attempt to submit.Technical Implementation
Target File
components/hackathons/submissions/SubmissionForm.tsxHook
useHackathonData()from@/lib/providers/hackathonProviderto accesscurrentHackathonsubmission settingsrequireGithub,requireDemoVideo, etc.) must be read directly from the hackathon context — never hardcoded or assumedLogic Mapping
Schema Validation —
submissionSchema(Zod)submissionSchemato conditionally enforce required fields based on the hackathon's requirement flagsrequireGithubistrue, the schema must treat the absence of a GitHub link in thelinksarray as a validation failure — the error should be surfaced at thelinksfield level, not as a generic form errorrequireDemoVideoistrue, the schema must enforce thatvideoUrlis a non-empty, valid URLform.setError()in the appropriate step handler rather than contorting the schemaStep Validation —
handleNext(Step 2)handleNextat Step 2, before allowing progression, explicitly checkcurrentHackathon.requireGithubtrueand no GitHub link is present inform.watch('links'), block progression and inject a clear, field-level validation error directing the user to add their GitHub repository linkrequire*flags that gate step progressionForm Submission —
onSubmitonSubmitthat re-checks allrequire*flags against the current form values before the submission payload is constructed and dispatchedonSubmitmust catch it before any API call is madeUI — Required Field Indicators
*) to the label of anyFormFieldwhose correspondingrequire*flag istruevideoUrl(whenrequireDemoVideoistrue) and the GitHub entry in thelinkssection (whenrequireGithubistrue)*must be driven by the flag values fromuseHackathonData()— it must not be hardcoded on the label"* Required for this hackathon") so users understand what the asterisk means without ambiguityrequire*flags must be sourced fromuseHackathonData(); never hardcode which fields are requiredanytypes in schema definitions or validation logicTesting & Verification
Automated Tests
Manual Verification
requireGithub: trueand attempt to proceed at Step 2 without a GitHub link — confirm progression is blocked with a clear, field-level validation error on thelinksfieldrequireGithub: trueand add a valid GitHub link — confirm progression is allowed and no erroneous validation error is shownrequireDemoVideo: trueand attempt to submit without avideoUrl— confirm the field fails validation with a clear, actionable error messagerequireDemoVideo: false— confirmvideoUrlis not required and the form submits successfully without it*) appears onvideoUrllabel whenrequireDemoVideoistrueand is absent whenfalse*) appears on the GitHub link label whenrequireGithubistrueand is absent whenfalseonSubmitcatches and blocks the submission with appropriate field errorsrequire*flags set tofalse— confirm no fields are marked required and the form submits successfully with only the base required fieldsanytypes are present in the schema or validation logic