Skip to content

fix: reject inverted budget ranges in createJobSchema#3367

Open
AlvaroWhiteRD wants to merge 1 commit into
SecureBananaLabs:mainfrom
AlvaroWhiteRD:fix/inverted-budget-validation
Open

fix: reject inverted budget ranges in createJobSchema#3367
AlvaroWhiteRD wants to merge 1 commit into
SecureBananaLabs:mainfrom
AlvaroWhiteRD:fix/inverted-budget-validation

Conversation

@AlvaroWhiteRD
Copy link
Copy Markdown

Problem

createJobSchema accepts payloads where budgetMax is lower than budgetMin, creating invalid job records (e.g. $500-100 budget range).

Solution

  • Extracted base Zod object schema to allow refinement on both create and update schemas
  • Added .refine() check ensuring budgetMax >= budgetMin when both fields are present
  • updateJobSchema (partial) also validates the range when both budget fields are provided
  • Added 8 regression tests covering valid ranges, inverted ranges, equal values, partial updates, and missing fields

Test Results

All 9 tests pass (8 new + 1 existing health test).

Files Changed

  • apps/api/src/validators/job.js — Added budget range refinement
  • apps/api/src/tests/job.test.js — New test file (8 tests)

Closes #2853

- Extract base schema to allow refinement on both create and update schemas
- Add refine check ensuring budgetMax >= budgetMin when both fields present
- updateJobSchema (partial) also validates range when both budget fields provided
- Add 8 regression tests covering valid ranges, inverted ranges, equal values,
  partial updates, and missing fields

Closes SecureBananaLabs#2853
github-actions Bot added a commit that referenced this pull request Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Job validation should reject inverted budget ranges

1 participant