✅ Category Validator Blocks
Category validator blocks provide validation functions for category-related operations in Nodeblocks applications. These validators ensure data integrity and proper business logic validation for category operations.
🎯 Overview
Category validator blocks are designed to:
- Validate category existence before operations
- Ensure data integrity in category workflows
- Provide reusable validation logic for category operations
- Support composition with other category blocks
- Handle error cases with proper error responses
📋 Category Validator Types
Existence Validators
Validators that check if categories exist in the database.
🔧 Available Category Validators
doesCategoryExist
Validates that a category exists in the database by checking the categoryId parameter.
Purpose: Ensures the requested category exists before proceeding with operations
Parameters:
payload
: RouteHandlerPayload containing context and paramspayload.context.db
: Database connection with categories collectionpayload.params.requestParams.categoryId
: Category ID to validate
Returns: void
- Passes through if category exists
Throws: NodeblocksError (404) with message "Category does not exist" if category not found
Usage:
import { validators } from '@nodeblocks/backend-sdk';
const { doesCategoryExist } = validators;
// Usage in a route pipeline:
compose(categorySchema, doesCategoryExist, updateCategoryHandler);
🔗 Related Documentation
- Category Schema Blocks - Category data validation and contracts
- Category Handler Blocks - Category business logic functions
- Category Route Blocks - Category HTTP endpoint definitions
- Category Feature Blocks - Category composed features