Skip to main content
Version: 0.6.0 (Latest)

✅ 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 params
  • payload.context.db: Database connection with categories collection
  • payload.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;

withRoute({
-- snip --
validators: [doesCategoryExist]
});