This is a bug bounty to fix a validation error in a job creation schema. Currently, the system accepts job budget ranges where the maximum budget is lower than the minimum, leading to invalid records. The task is to implement validation logic to reject such inverted ranges during job creation and partial updates, while ensuring existing valid ranges remain unaffected.
A starter prompt for Claude Code, what you'll need, and how to reach them.
You are an expert software engineer. The task is to fix a bug in a job creation and update schema. The current schema allows `budgetMax` to be less than `budgetMin`, creating invalid job records. You need to implement validation to reject these inverted budget ranges. The solution should be implemented within a GitHub repository, likely in a Node.js/TypeScript environment using a validation library like Joi or Zod if present.
**Specific Requirements:**
1. **Locate Schema:** Identify the `createJobSchema` (or similar) responsible for validating new job payloads. If the exact schema isn't immediately obvious, start by searching for keywords like 'job', 'budget', 'schema', 'validation' within the repository.
2. **Implement Validation:** Add a custom validation rule or constraint to `createJobSchema` to ensure that `budgetMax` is strictly greater than or equal to `budgetMin` when both fields are provided.
3. **Handle Updates:** Apply the same validation logic to any schema or handler for partial job updates. This validation should only trigger if *both* `budgetMin` and `budgetMax` are present in the update payload.
4. **Preserve Existing:** Ensure that valid, already-ordered ranges in existing records continue to parse and are not inadvertently affected by the new validation logic (this is implicitly handled by focusing on creation/update validation).
5. **Testing:** Propose unit tests using a common Node.js testing framework (e.g., Jest) to cover:
* Successful creation of jobs with valid budget ranges (`budgetMin <= budgetMax`).
* Rejection of job creation with inverted budget ranges (`budgetMax < budgetMin`).
* Successful partial update of jobs with valid budget ranges.
* Rejection of partial updates with inverted budget ranges when both budget fields are provided.
* Successful partial updates when only one budget field is provided (validation should not trigger for inversion).
**Deliverable:** A pull request to a forked repository that addresses the bug and includes relevant tests. Your proposed solution should use a stack compatible with Node.js and modern JavaScript/TypeScript practices.
**Build/Verify Gate:** The validation logic correctly prevents inverted budget ranges, and all new tests pass.Bounty (amount on the issue). ## Bug `createJobSchema` currently accepts payloads where `budgetMax` is lower than `budgetMin`. That creates invalid job records such as a USD 500-100 budget range and can break client-side filtering, sorting, and display assumptions. ## Expected behavior - Job creation should reject inverted budget ranges. - Partial job updates should reject the same invalid range when both budget fields are present. - Existing valid ordered ranges should continue to parse successfully. This issue is limited only to the creator of this issue. This means that only the issue author can attempt to solve this issue. If you would like to work on it, please create another issue with the same contents and refer to issue #743 for more information. Parent bounty: #743
Standard for any developer.
Standard JavaScript runtime.
Standard version control tool.
Core competency for the operator.
Create a new GitHub issue as specified in the original issue's description, then open a draft Pull Request to the forked repository.
“I've created a new issue for this bug fix as instructed and have a working draft PR with validation logic and tests on my fork. I'm ready to submit for review.”
Open the original ↗