Skip to content

Comments

Chaitanya - Purchase request form enhancement#2034

Open
csk731 wants to merge 2 commits intodevelopmentfrom
chaitanya-purchase-req-form-enhancement-be
Open

Chaitanya - Purchase request form enhancement#2034
csk731 wants to merge 2 commits intodevelopmentfrom
chaitanya-purchase-req-form-enhancement-be

Conversation

@csk731
Copy link
Contributor

@csk731 csk731 commented Feb 8, 2026

Description

Implements backend validation, error handling, and structured error responses for the Purchase Request APIs to align with the frontend validation, feedback, and confirmation flow. Validation covers required fields (project, material, quantity, priority), data types (ObjectIds, numeric quantity), and business rules (quantity > 0, valid priority). All validation errors return a consistent { field, message } structure so the frontend can show field-specific inline errors.

image Screenshot 2026-02-07 at 11 08 03 PM

Related PRS (if any):

To test this backend PR you need to checkout the #4814 frontend PR.

Main changes explained:

  • Update HGNRest/src/controllers/bmdashboard/bmMaterialsController.js – Adds validation in bmPurchaseMaterials:
    Required fields: projectId, matTypeId, quantity, priority, requestorId. ObjectId checks for projectId, matTypeId, requestorId. Quantity: must be a valid number and > 0. Priority: must be Low, Medium, or High. All validation errors returned as { field, message } for field-specific frontend display 500 errors handled consistently

How to test:

  1. Check out the current branch.
  2. Run npm install and start the backend API locally.
  3. Ensure the frontend PR #4814 is checked out and running.
  4. Log in as an admin user.
  5. Go to /bmdashboard/materials/purchase.
  6. Valid submission: Submit a valid form – expect 201 and a successful purchase record.
  7. Check for worst cases: Invalid Project/ Material/Quantity/Priority. Backend Service Validates these all along with Frontend Service.

…Id, quantity, priority, and requestorId in bmMaterialsController.
@csk731 csk731 changed the title feat: Implement comprehensive input validation for projectId, matType… Chaitanya - Purchase request form enhancement Feb 8, 2026
Copy link

@Anusha-Gali Anusha-Gali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Chaitanya,

I have reviewed your PR locally and it works as expected. Find my comment in frontend pr: OneCommunityGlobal/HighestGoodNetworkApp#4814 (review)

Image

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.

2 participants