Skip to main content
Version: 🚧 Canary

🪪 Identity Validator Blocks

Identity validator blocks provide validation functions for identity-related operations. These validators ensure proper access control for identity resources.


🎯 Overview

Identity validator blocks are designed to:

  • Validate self-access to identity resources
  • Support identity-type based gating via common validators

📋 Identity Validator Types

Access Control Validators

Validators that check permissions for identity resources.


🔧 Available Identity Validators

isSelf

Validates that the authenticated user is accessing their own identity resource.

Purpose: Ensures an identity can access only its own resources

Parameters:

  • identityIdPathInPayload: tuple path to target identityId in payload (e.g. ['params', 'requestParams', 'identityId'])

Returns: void - Passes through if the target identityId matches the authenticated identity

Throws:

  • NodeblocksError (401) with message "Invalid token"
  • NodeblocksError (403) with message "Identity ID is required"
  • NodeblocksError (403) with message "Identity ID does not match"

Usage:

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

const { isSelf } = validators;

withRoute({
-- snip --
validators: [
isSelf(['params', 'requestParams', 'identityId'])
],
});