🔍 Identity Schema Blocks
Identity schema blocks provide JSON Schema definitions for identity data validation in NodeBlocks applications. These schemas ensure data integrity and provide clear contracts for identity-related API endpoints.
🎯 Overview
Identity schema blocks are designed to:
- Validate identity data before processing
- Ensure identity data consistency across the application
- Provide clear contracts for identity API endpoints
- Enable type safety with TypeScript integration
- Support composition with other identity blocks
📋 Identity Schema Types
Base Identity Schemas
Core identity entity structures used as foundations for other schemas.
Identity Retrieval Schemas
Schemas for getting specific identities with identifier validation.
Identity Update Schemas
Schemas for identity modifications with optional field validation.
Identity Search Schemas
Schemas for identity filtering and pagination parameters.
Identity Deletion Schemas
Schemas for identity removal operations.
🔧 Available Identity Schemas
identityIdPathParameter
Base identity ID path parameter schema for identity operations.
Purpose: Reusable path parameter schema for identity ID validation across all identity operations
Schema Details:
- Type:
string
- Location:
path
- Required:
true
- Name:
identityId
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { identityIdPathParameter } = schemas;
// Use in schema composition
export const getIdentitySchema = withSchema({
parameters: [{ ...identityIdPathParameter }]
});
getIdentitySchema
Identity retrieval schema with identity ID validation.
Purpose: This schema validates requests for retrieving specific identities by their unique identifier. It ensures the identityId is provided and properly formatted.
Schema Details:
- Parameters:
identityId
(path parameter, required) - Purpose: Validates requests for retrieving specific identities
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { getIdentitySchema } = schemas;
const identitySchema = getIdentitySchema({});
const validate = ajv.compile(identitySchema.schemas as SchemaDefinition);
const isValid = validate({
identityId: 'identity123'
});
findIdentitySchema
Identity search schema with name filtering and pagination.
Purpose: This schema validates requests for searching and paginating identities. It supports optional name filtering and standard pagination parameters.
Schema Details:
- Query Parameters:
name?: string
(optional filter by name)page?: number
(pagination)limit?: number
(pagination)
- Purpose: Validates requests for searching and paginating identities
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { findIdentitySchema } = schemas;
const identitySchema = findIdentitySchema({});
const validate = ajv.compile(identitySchema.schemas as SchemaDefinition);
const isValid = validate({
name: 'john',
page: 1,
limit: 10
});
updateIdentitySchema
Identity update schema with modifiable fields validation.
Purpose: This schema validates requests for updating identity information. It allows partial updates to identity fields while ensuring only valid fields can be modified.
Schema Details:
- Parameters:
identityId
(path parameter, required) - Request Body:
required
- Content-Type:
application/json
- Properties:
email?: string
(optional new email address)emailVerified?: boolean
(optional email verification status)typeId?: string
(optional new identity type identifier)
- Additional Properties:
false
(strict validation)
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { updateIdentitySchema } = schemas;
const identitySchema = updateIdentitySchema({});
const validate = ajv.compile(identitySchema.schemas as SchemaDefinition);
const isValid = validate({
identityId: 'identity123',
email: 'newemail@example.com',
emailVerified: true
});
deleteIdentitySchema
Identity deletion schema with identifier validation.
Purpose: This schema validates requests for deleting specific identities. It ensures the identityId is provided for the deletion operation.
Schema Details:
- Parameters:
identityId
(path parameter, required) - Purpose: Validates requests for deleting specific identities
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { deleteIdentitySchema } = schemas;
const identitySchema = deleteIdentitySchema({});
const validate = ajv.compile(identitySchema.schemas as SchemaDefinition);
const isValid = validate({
identityId: 'identity123'
});