-
Notifications
You must be signed in to change notification settings - Fork 77
Open
Labels
Beta-Campaigndifficulty: mediumenhancementNew feature or requestNew feature or requestfrontendhelp wantedExtra attention is neededExtra attention is needed
Description
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/hackathonProviderto accesscurrentHackathonsubmission 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
submissionSchemato conditionally enforce required fields based on the hackathon's requirement flags - If
requireGithubistrue, 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 error - If
requireDemoVideoistrue, the schema must enforce thatvideoUrlis 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
handleNextat Step 2, before allowing progression, explicitly checkcurrentHackathon.requireGithub - If
trueand 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 link - Apply the same pattern for any other
require*flags that gate step progression
Form Submission — onSubmit
- Perform a final validation pass in
onSubmitthat re-checks allrequire*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,
onSubmitmust 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 anyFormFieldwhose correspondingrequire*flag istrue - Affected fields include at minimum:
videoUrl(whenrequireDemoVideoistrue) and the GitHub entry in thelinkssection (whenrequireGithubistrue) - The
*must be driven by the flag values fromuseHackathonData()— 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 fromuseHackathonData(); 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
anytypes 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 typesManual Verification
- Set
requireGithub: trueand attempt to proceed at Step 2 without a GitHub link — confirm progression is blocked with a clear, field-level validation error on thelinksfield - Set
requireGithub: trueand add a valid GitHub link — confirm progression is allowed and no erroneous validation error is shown - Set
requireDemoVideo: trueand attempt to submit without avideoUrl— confirm the field fails validation with a clear, actionable error message - Set
requireDemoVideo: false— confirmvideoUrlis not required and the form submits successfully without it - Verify the asterisk (
*) appears onvideoUrllabel whenrequireDemoVideoistrueand is absent whenfalse - Verify the asterisk (
*) appears on the GitHub link label whenrequireGithubistrueand is absent whenfalse - Attempt to bypass step-level validation and submit directly — confirm
onSubmitcatches and blocks the submission with appropriate field errors - Confirm all validation errors are surfaced as field-level errors, not generic form-level alerts
- Test with all
require*flags set tofalse— confirm no fields are marked required and the form submits successfully with only the base required fields - Confirm no TypeScript
anytypes are present in the schema or validation logic - Provide video evidence
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Beta-Campaigndifficulty: mediumenhancementNew feature or requestNew feature or requestfrontendhelp wantedExtra attention is neededExtra attention is needed