Skip to main content
Version: 0.5.0 (Previous)

🖼️ Avatar Schema Blocks

Avatar schema blocks provide JSON Schema definitions for avatar objects used across domains (e.g., user profiles, organizations). These schemas ensure consistent object structure for file references stored in cloud storage.


🎯 Overview

Avatar schemas are designed to:

  • Validate avatar object shape used in entities
  • Ensure required fields are always present
  • Integrate with file storage flows using objectId

🔧 Available Avatar Schemas

avatarSchema

Base avatar object schema.

Purpose: Validates avatar object with storage reference and MIME type

Schema Details:

  • Type: object
  • Required Fields: objectId, type
  • Additional Properties: false (strict validation)
  • Properties:
    • objectId: string (UUID) — Cloud Storage object identifier
    • type: string — MIME type of the image (e.g., image/png)

Usage:

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

const { avatarSchema } = schemas;

const validate = ajv.compile(avatarSchema as SchemaDefinition);
const isValid = validate({ objectId: 'b1f6c9b2-0a10-4c51-8b1f-1a9a2b1d8f90', type: 'image/png' });