メインコンテンツまでスキップ
バージョン: 0.7.0 (Previous)

🔍 Product Schemas

Product schemas provide JSON Schema definitions for product data validation in Nodeblocks applications. These schemas ensure data integrity and provide clear contracts for product-related API endpoints.


🎯 Overview​

Product schemas are designed to:

  • Validate product data before processing
  • Support product images with metadata and type validation
  • Handle image arrays with automatic base entity assignment
  • Support batch operations for bulk product management
  • Enable product duplication and copying workflows
  • Handle product search and filtering capabilities
  • Provide flexible product structures for various use cases
  • Support efficient bulk updates and deletions

📋 Product Schema Types​

Base Product Schemas​

Core product structures used as foundations for other schemas.

Product Image Schemas​

Schemas for product image validation with objectId and type fields.

Product Creation Schemas​

Schemas for product creation with required field validation including images.

Product Update Schemas​

Schemas for product modifications with optional field validation.

Product Batch Operation Schemas​

Schemas for batch creation, update, deletion, and duplication with image support.

Product Query Schemas​

Schemas for product filtering and pagination parameters.


🔧 Available Product Schemas​

productSchema​

Base product schema defining the structure for product data.

Purpose: Defines basic product structure for reuse across other schemas

Schema Details:

  • Type: object
  • Required Fields: None (base schema)
  • Additional Properties: false (strict validation)
  • Properties:
    • name?: string - Product name
    • description?: string - Product description

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { productSchema } = schemas;

const validate = ajv.compile(productSchema as SchemaDefinition);
const isValid = validate({ name: 'Product Name', description: 'Description' });

productImageSchema​

Product image schema with metadata validation for image management.

Purpose: Defines the structure for product images with object identifiers and type information

Schema Details:

  • Type: object
  • Required Fields: None (base schema)
  • Additional Properties: false (strict validation)
  • Properties:
    • objectId?: string - UUID format object identifier referencing the image file
    • type?: string - Image type classification (e.g., 'image/png', 'image/jpeg')

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

// Used in product creation:
const productImage = {
objectId: '550e8400-e29b-41d4-a716-446655440000',
type: 'image/png'
};

createProductImageSchema​

Product image creation schema with required fields validation.

Purpose: Validates product image data for creation requests

Schema Details:

  • Type: object
  • Required Fields: objectId, type
  • Additional Properties: false (strict validation)
  • Content-Type: application/json
  • Request Body: required

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { createProductImageSchema } = schemas;

const schema = createProductImageSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
objectId: '550e8400-e29b-41d4-a716-446655440000',
type: 'image/png'
});

imageIdPathParameter​

Image ID path parameter schema for product image operations.

Purpose: Defines the imageId path parameter used in image-specific routes

Parameter Details:

  • Location: path (URL path)
  • Name: imageId
  • Required: true
  • Type: string

Usage:

// Used in route definitions:
const getImageRoute = withRoute({
path: '/products/:productId/images/:imageId',
parameters: [imageIdPathParameter]
});

deleteProductImageSchema​

Product image deletion schema with path parameter validation.

Purpose: Validates DELETE requests for removing product images

Schema Details:

  • Parameters: productId (path parameter, required), imageId (path parameter, required)
  • Purpose: Validates both product ID and image ID are present in the request path

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { deleteProductImageSchema } = schemas;

// Applied in feature composition:
export const deleteProductImageFeature = compose(
deleteProductImageSchema,
deleteProductImageRoute
);

Path Parameters:

ParameterTypeRequiredDescription
productIdstring✅Product identifier
imageIdstring✅Image identifier to delete

TypeScript Types​

ProductImage​

Type definition for product image data structure.

type ProductImage = {
objectId: string; // UUID format object identifier
type: string; // Image MIME type (e.g., 'image/png', 'image/jpeg')
};

Usage:

import { ProductImage } from '@nodeblocks/backend-sdk';

const productImage: ProductImage = {
objectId: '550e8400-e29b-41d4-a716-446655440000',
type: 'image/png'
};

NormalizedProductImage​

Type definition for normalized product image with URL.

type NormalizedProductImage = {
url: string; // Full URL to the image resource
type: string; // Image MIME type
};

Usage:

import { NormalizedProductImage } from '@nodeblocks/backend-sdk';

const normalizedImage: NormalizedProductImage = {
url: 'https://storage.example.com/images/product123.png',
type: 'image/png'
};

createProductSchema​

Product creation schema with required fields for new products.

Purpose: Validates product data during creation

Schema Details:

  • Type: object
  • Required Fields: name, description
  • Additional Properties: false (strict validation)
  • Content-Type: application/json
  • Request Body: required

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { createProductSchema } = schemas;

const schema = createProductSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
name: 'Product Name',
description: 'Description'
});

updateProductSchema​

Product update schema with optional fields for product modifications.

Purpose: Validates partial product data updates

Schema Details:

  • Type: object
  • Required Fields: None (all fields optional)
  • Additional Properties: false (strict validation)
  • Content-Type: application/json
  • Parameters: productId (path parameter)
  • Request Body: required

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { updateProductSchema } = schemas;

const schema = updateProductSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ description: 'Updated description' });

createProductBatchSchema​

Product batch creation schema for creating multiple products at once.

Purpose: Validates arrays of product data for bulk creation

Schema Details:

  • Type: array
  • Required Fields: name, description (for each item)
  • Additional Properties: false (strict validation)
  • Content-Type: application/json
  • Request Body: required

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { createProductBatchSchema } = schemas;

const schema = createProductBatchSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate([
{
name: 'Product 1',
description: 'Desc 1'
},
{
name: 'Product 2',
description: 'Desc 2'
}
]);

updateProductBatchSchema​

Product batch update schema for updating multiple products with same data.

Purpose: Validates bulk product updates with product IDs and update data

Schema Details:

  • Type: object
  • Required Fields: ids, data
  • Additional Properties: false (strict validation)
  • Content-Type: application/json
  • Request Body: required

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { updateProductBatchSchema } = schemas;

const schema = updateProductBatchSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ ids: ['id1', 'id2'], data: { name: 'Updated' } });

deleteProductBatchSchema​

Product batch deletion schema for removing multiple products by IDs.

Purpose: Validates arrays of product IDs for bulk deletion

Schema Details:

  • Type: array
  • Items: string (product IDs)
  • Content-Type: application/json
  • Request Body: required

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { deleteProductBatchSchema } = schemas;

const schema = deleteProductBatchSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate(['id1', 'id2', 'id3']);

copyProductBatchSchema​

Product batch copy schema for duplicating multiple products by IDs.

Purpose: Validates arrays of product IDs for bulk duplication

Schema Details:

  • Type: array
  • Items: string (product IDs)
  • Content-Type: application/json
  • Request Body: required

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { copyProductBatchSchema } = schemas;

const schema = copyProductBatchSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate(['id1', 'id2', 'id3']);

getProductSchema​

Product retrieval schema for getting single products by ID.

Purpose: Validates requests for retrieving specific products

Schema Details:

  • Parameters: productId (path parameter)
  • Purpose: Validates requests for retrieving specific products

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { getProductSchema } = schemas;

const schema = getProductSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ productId: 'prod123' });

deleteProductSchema​

Product deletion schema for removing products by ID.

Purpose: Validates requests for deleting specific products

Schema Details:

  • Parameters: productId (path parameter)
  • Purpose: Validates requests for deleting specific products

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { deleteProductSchema } = schemas;

const schema = deleteProductSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ productId: 'prod123' });

copyProductSchema​

Product copy schema for duplicating products by ID.

Purpose: Validates requests for duplicating specific products

Schema Details:

  • Parameters: productId (path parameter)
  • Purpose: Validates requests for duplicating specific products

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { copyProductSchema } = schemas;

const schema = copyProductSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ productId: 'prod123' });

findProductsSchema​

Product search schema for finding products with optional filtering and pagination.

Purpose: Validates requests for searching and paginating products

Schema Details:

  • Query Parameters:
    • name?: string - Filter by product name
    • description?: string - Filter by product description
    • page?: number - Pagination page number
    • limit?: number - Pagination limit
  • Purpose: Validates requests for searching and paginating products

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { findProductsSchema } = schemas;

const schema = findProductsSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ name: 'Product', page: 1, limit: 10 });

createProductVariantSchema​

Product variant creation schema with required title and optional variant fields.

Purpose: Validates product variant data during creation with pricing and image support

Schema Details:

  • Type: object
  • Required Fields: title
  • Optional Fields: description, sku, imageIds, price
  • Additional Properties: false (strict validation)
  • Content-Type: application/json
  • Parameters: productId (path parameter)
  • Request Body: required

Price Object Structure:

{
"amount": "number (optional)",
"currency": "string (optional)",
"taxIncluded": "boolean (optional)",
"taxable": "boolean (optional)"
}

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { createProductVariantSchema } = schemas;

const schema = createProductVariantSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
title: 'Blue Baseball Cap',
description: 'Premium baseball cap in blue color',
sku: 'BBC-BLUE',
imageIds: ['img-456', 'img-789'],
price: {
amount: 2999,
currency: 'USD',
taxIncluded: false,
taxable: true
}
});

Schema Structure:

{
productId: string; // required - path parameter for parent product
}

// Request body structure:
{
title: string; // required - variant title/name
description?: string; // optional - variant description
sku?: string; // optional - stock keeping unit
imageIds?: string[]; // optional - array of image identifiers
price?: { // optional - pricing information
amount?: number; // optional - price amount
currency?: string; // optional - ISO currency code
taxIncluded?: boolean; // optional - whether tax is included
taxable?: boolean; // optional - whether variant is taxable
};
}

Key Features:

  • Required Title: Every variant must have a descriptive title
  • Flexible Pricing: All price fields are optional for future updates
  • Image References: Supports linking to existing product images
  • SKU Support: Optional stock keeping unit for inventory management
  • Parent Product Context: Requires productId path parameter to associate with parent product

Validation Rules:

  • No additional properties allowed (strict schema)
  • Title must be a non-empty string
  • Image IDs must be valid strings if provided
  • Price amounts must be numbers if provided

createProductVariantBulkSchema​

Product variant bulk creation schema with array validation and size limits.

Purpose: Validates requests for creating multiple product variants in a single operation with path parameter product association and comprehensive constraints.

Schema Details:

  • Type: array
  • Required Fields: title (for each item)
  • Optional Fields: description, sku, price, imageIds, isActive (for each item)
  • Additional Properties: false (strict validation per item)
  • Content-Type: application/json
  • Request Body: required
  • Path Parameters: productId (required - product identifier from URL path)

Array Constraints:

  • Minimum Items: 1 (at least one variant required)
  • Maximum Items: 100 (prevents excessive bulk operations)
  • Unique Items: Not enforced (variants can be similar)

Item Schema Structure:

{
title: string; // required - variant display name
description?: string; // optional - variant description
sku?: string; // optional - stock keeping unit
price?: { // optional - pricing information
amount?: number; // optional - price amount
currency?: string; // optional - ISO currency code
};
imageIds?: string[]; // optional - array of image identifiers
isActive?: boolean; // optional - availability status
}

Key Features:

  • Bulk Validation: Validates entire array of variants in single operation
  • Individual Requirements: Each variant must have title field
  • Path Parameter Validation: Product ID provided via URL path parameter
  • Flexible Fields: Most fields optional for batch creation flexibility
  • Size Limits: Prevents extremely large bulk operations
  • Product Association: All variants linked to product via path parameter

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { createProductVariantBulkSchema } = schemas;

const schema = createProductVariantBulkSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate([
{
title: 'Small - Red',
sku: 'S-RED',
price: { amount: 1999, currency: 'USD' }
},
{
title: 'Medium - Blue',
sku: 'M-BLUE',
price: { amount: 2099, currency: 'USD' }
}
]);

Validation Rules:

  • Array must contain 1-100 items
  • Each item must have title field
  • Path parameter productId is required
  • No additional properties allowed in individual items
  • Price object structure follows standard pricing schema
  • Image IDs must be valid strings if provided
  • SKU must be string if provided

Common Validation Errors:

  • Missing required title field in variant items
  • Path parameter productId is missing or invalid
  • Array size outside 1-100 range
  • Invalid data types for optional fields
  • Additional properties in request items

updateProductVariantBulkSchema​

Product variant bulk update schema with bulk operation validation.

Purpose: Validates requests for updating multiple product variants in a single operation with comprehensive constraints and data validation.

Schema Details:

  • Type: object
  • Required Fields: ids, data (request body), productId (path parameter)
  • Optional Fields: Various product variant fields in the data object
  • Content-Type: application/json
  • Request Body: required
  • Path Parameters: productId (required - product identifier from URL path)

Schema Structure:

{
parameters: [{ productId: string }]; // required - product ID path parameter
requestBody: { // required - bulk update payload
content: {
'application/json': {
schema: {
ids: string[]; // required - array of variant IDs (1-100 items)
data: { // required - variant update data
description?: string; // optional - variant description
imageIds?: string[]; // optional - array of image IDs
price?: { // optional - pricing information
amount: number; // required - price amount
currency: string; // required - currency code
taxIncluded: boolean; // required - whether tax is included
taxable: boolean; // required - whether item is taxable
};
sku?: string; // optional - stock keeping unit
title?: string; // optional - variant title
};
required: ['ids', 'data'] // required fields in request body
}
}
}
}
}

Key Features:

  • Bulk Validation: Validates entire bulk update payload in single operation
  • Size Limits: Restricts ID array to 1-100 items for performance
  • Flexible Updates: All product variant fields optional in update data
  • Path Parameter Validation: Ensures productId is provided in URL path
  • Type Safety: Comprehensive validation of nested objects and arrays

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { updateProductVariantBulkSchema } = schemas;

const schema = updateProductVariantBulkSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
parameters: [{ productId: 'prod-123' }],
requestBody: {
content: {
'application/json': {
schema: {
ids: ['var-123', 'var-456'],
data: {
description: 'Updated description',
price: { amount: 2999, currency: 'USD', taxIncluded: true, taxable: true }
}
}
}
}
}
});

Validation Rules:

  • productId path parameter is required and must be a valid string
  • ids array must contain 1-100 variant ID strings
  • data object must be present and contain valid product variant fields
  • All fields in data are optional (for partial updates)
  • Price object structure follows standard pricing schema when provided
  • Image IDs must be valid strings if provided
  • No additional properties allowed in the request body

Common Validation Errors:

  • Missing required productId path parameter
  • Missing required ids or data fields in request body
  • ID array size outside 1-100 range
  • Invalid data types for optional fields
  • Additional properties in request body
  • Invalid nested object structures (e.g., malformed price object)

deleteProductVariantBulkSchema​

Product variant bulk deletion schema with variant ID array validation.

Purpose: Validates requests for bulk deletion of product variants with comprehensive constraints and size limits.

Schema Details:

  • Type: array
  • Required Fields: Array of strings (variant IDs), productId (path parameter)
  • Content-Type: application/json
  • Request Body: required
  • Path Parameters: productId (required - product identifier from URL path)

Schema Structure:

{
parameters: [{ productId: string }]; // required - product ID path parameter
requestBody: {
content: {
'application/json': {
schema: string[]; // required - array of variant IDs (1-100 items)
};
};
required: true;
};
}

Key Features:

  • Array Validation: Validates entire array of variant ID strings
  • Size Limits: Restricts array to 1-100 items for performance
  • Path Parameter Validation: Ensures productId is provided in URL path
  • Type Safety: Comprehensive validation of array structure and string types

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { deleteProductVariantBulkSchema } = schemas;

const schema = deleteProductVariantBulkSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
parameters: [{ productId: 'prod-123' }],
requestBody: {
content: {
'application/json': {
schema: ['var-123', 'var-456', 'var-789']
}
}
}
});

Validation Rules:

  • productId path parameter is required and must be a valid string
  • Request body must be an array of strings
  • Array must contain 1-100 variant ID strings
  • No additional properties allowed in the request body

Common Validation Errors:

  • Missing required productId path parameter
  • Request body is not an array
  • Array contains fewer than 1 or more than 100 items
  • Array contains non-string values
  • Additional properties in request body

getProductVariantSchema​

Product variant retrieval schema with required path parameters validation.

Purpose: Validates requests for retrieving individual product variants by their IDs

Schema Details:

  • Type: object
  • Required Fields: productId, productVariantId (both path parameters)
  • Additional Properties: false (strict validation)

Schema Structure:

{
productId: string; // required - parent product identifier (path)
productVariantId: string; // required - product variant identifier (path)
}

Key Features:

  • Path Parameter Validation: Ensures both product and variant IDs are provided
  • Strict Validation: No additional properties allowed
  • Simple Structure: Only validates the required path parameters

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { getProductVariantSchema } = schemas;

const schema = getProductVariantSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
productId: 'prod-123',
productVariantId: 'var-456'
});

Validation Rules:

  • productId must be a valid string (required)
  • productVariantId must be a valid string (required)
  • No additional properties allowed in the request

updateProductVariantSchema​

Product variant update schema with optional fields validation.

Purpose: Validates partial updates to existing product variants with all fields optional

Schema Details:

  • Type: object
  • Required Fields: None (all fields optional)
  • Optional Fields: title, description, sku, imageIds, price
  • Additional Properties: false (strict validation)
  • Content-Type: application/json
  • Parameters: productId, productVariantId (both required path parameters)
  • Request Body: required (but can be empty object for no-op updates)

Schema Structure:

{
productId: string; // required - parent product identifier (path)
productVariantId: string; // required - product variant identifier (path)
}

// Request body structure (all fields optional):
{
title?: string; // optional - product variant title
description?: string; // optional - variant description
sku?: string; // optional - stock keeping unit
imageIds?: string[]; // optional - array of image identifiers
price?: { // optional - pricing information
amount?: number; // optional - price amount
currency?: string; // optional - ISO currency code
taxIncluded?: boolean; // optional - whether tax is included
taxable?: boolean; // optional - whether variant is taxable
};
}

Key Features:

  • Partial Updates: All fields are optional, allowing targeted updates
  • Flexible Pricing: Price object fields are all optional for incremental updates
  • Image Management: Can update image references without affecting other fields
  • Path Parameter Validation: Ensures both product and variant IDs are provided
  • Strict Validation: No additional properties allowed

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { updateProductVariantSchema } = schemas;

const schema = updateProductVariantSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
productId: 'prod-123',
productVariantId: 'var-456'
}, {
price: {
amount: 2999,
currency: 'USD'
}
});

Validation Rules:

  • Path parameters productId and productVariantId are required
  • Request body can be empty object (no-op update)
  • All request body fields are optional
  • imageIds must be an array of strings if provided
  • Price object structure follows the defined schema
  • No additional properties allowed in request body

deleteProductVariantSchema​

Product variant deletion schema with required path parameters validation.

Purpose: Validates requests for deleting individual product variants by their IDs

Schema Details:

  • Type: object
  • Required Fields: productId, productVariantId (both path parameters)
  • Additional Properties: false (strict validation)

Schema Structure:

{
productId: string; // required - parent product identifier (path)
productVariantId: string; // required - product variant identifier (path)
}

Key Features:

  • Path Parameter Validation: Ensures both product and variant IDs are provided
  • Simple Structure: Only validates required path parameters for deletion
  • No Request Body: DELETE operations don't require a request body

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { deleteProductVariantSchema } = schemas;

const schema = deleteProductVariantSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
productId: 'prod-123',
productVariantId: 'var-456'
});

Validation Rules:

  • productId must be a valid string (required path parameter)
  • productVariantId must be a valid string (required path parameter)
  • No additional properties allowed in the request

findProductVariantsSchema​

Product variants retrieval schema with pagination and product ID validation.

Purpose: Validates requests for retrieving product variants with optional pagination parameters

Schema Details:

  • Type: object
  • Required Fields: productId (path parameter)
  • Optional Fields: page, limit, sort, order (query parameters)
  • Additional Properties: false (strict validation)

Schema Structure:

{
productId: string; // required - product identifier from path parameter
page?: number; // optional - page number for pagination
limit?: number; // optional - number of items per page
sort?: string; // optional - sorting field
order?: "asc" | "desc"; // optional - sort order direction
}

Key Features:

  • Path Parameter Validation: Ensures product ID is provided in URL path
  • Pagination Support: Optional query parameters for page navigation
  • Sorting Options: Optional sort field and order direction
  • Flexible Filtering: Extends pagination schema for consistent pagination behavior

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { findProductVariantsSchema } = schemas;

const schema = findProductVariantsSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
productId: 'prod-123',
page: 1,
limit: 10,
sort: 'createdAt',
order: 'desc'
});

Validation Rules:

  • productId must be a valid string (required path parameter)
  • page must be a number ≥ 1 if provided
  • limit must be a number between 1-100 if provided
  • sort must be a string if provided
  • order must be either "asc" or "desc" if provided
  • No additional properties allowed in the request

getProductLikersSchema​

Product likers retrieval schema with product ID path parameter validation.

Purpose: Validates requests for retrieving users who have liked a specific product with pagination support.

Schema Details:

  • Parameters: productId (path parameter)
  • Type: object
  • Required Fields: productId (path parameter)
  • Optional Fields: page, limit, sort, order (query parameters for pagination)
  • Additional Properties: false (strict validation)

Schema Structure:

{
parameters: {
productId: string; // required - product identifier for likers lookup
};
query?: { // optional - pagination parameters
page?: number; // optional - page number for pagination
limit?: number; // optional - number of items per page
sort?: string; // optional - field to sort by
order?: string; // optional - sort order direction
};
}

Key Features:

  • Path Parameter Validation: Ensures product ID is provided in URL path
  • Pagination Support: Optional query parameters for page navigation and sorting
  • Simple Structure: Focused on validating the product ID parameter for likers retrieval

Usage:

import { schemas } from '@nodeblocks/backend-sdk';

const { getProductLikersSchema } = schemas;

const schema = getProductLikersSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
parameters: { productId: 'prod-123' },
query: { page: 1, limit: 10 }
});

Validation Rules:

  • productId must be a valid string (required path parameter)
  • page must be a number ≥ 1 if provided
  • limit must be a number between 1-100 if provided
  • sort must be a string if provided
  • order must be either "asc" or "desc" if provided
  • No additional properties allowed in the request