Skip to main content
Version: 0.5.0 (Previous)

📍 Address Schema Blocks

Address schema blocks provide JSON Schema definitions for address validation in different formats and regions. These schemas ensure consistent address data validation across Nodeblocks applications.


🎯 Overview​

Address schema blocks are designed to:

  • Validate address data in various formats and regions
  • Support international addresses with region-specific requirements
  • Ensure address consistency across the application
  • Provide flexible address storage with array-based formats
  • Support composition with other address-related schemas

📋 Address Schema Types​

Base Address Schemas​

Core address component schemas used as foundations for complete address structures.

Regional Address Schemas​

Complete address schemas for specific regions and formats.

Address Component Schemas​

Individual address component validation schemas.


🔧 Available Address Schemas​

address​

Address array schema for flexible address line storage.

Purpose: Validates arrays of address line strings for flexible address storage

Schema Details:

  • Type: object
  • Additional Properties: false (strict validation)
  • Properties:
    • address?: string[] - Array of address line strings

Usage:

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

const { address } = schemas;

const validate = ajv.compile(address as SchemaDefinition);
const isValid = validate({ address: ['123 Main St', 'Apt 4'] });

postalCode​

Postal code schema for postal code validation.

Purpose: Validates postal code strings for address formatting

Schema Details:

  • Type: object
  • Additional Properties: false (strict validation)
  • Properties:
    • postalCode?: string - Postal code string

Usage:

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

const { postalCode } = schemas;

const validate = ajv.compile(postalCode as SchemaDefinition);
const isValid = validate({ postalCode: '12345' });

prefecture​

Prefecture schema for Japanese prefecture validation.

Purpose: Validates prefecture strings or null values for Japanese addresses

Schema Details:

  • Type: object
  • Additional Properties: false (strict validation)
  • Properties:
    • prefecture?: string | null - Prefecture string or null

Usage:

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

const { prefecture } = schemas;

const validate = ajv.compile(prefecture as SchemaDefinition);
const isValid = validate({ prefecture: 'Tokyo' });

city​

City schema for city name validation.

Purpose: Validates city name strings for address components

Schema Details:

  • Type: object
  • Additional Properties: false (strict validation)
  • Properties:
    • city?: string - City name string

Usage:

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

const { city } = schemas;

const validate = ajv.compile(city as SchemaDefinition);
const isValid = validate({ city: 'Tokyo' });

country​

Country schema for country name validation.

Purpose: Validates country name strings for address components

Schema Details:

  • Type: object
  • Additional Properties: false (strict validation)
  • Properties:
    • country?: string - Country name string

Usage:

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

const { country } = schemas;

const validate = ajv.compile(country as SchemaDefinition);
const isValid = validate({ country: 'Japan' });

addressJPSchema​

Japanese address schema with comprehensive address components.

Purpose: Validates complete Japanese address structure with all components

Schema Details:

  • Type: object
  • Additional Properties: false (strict validation)
  • Properties:
    • city?: string - City name
    • country?: string - Country name
    • postalCode?: string - Postal code
    • prefecture?: string - Prefecture name
    • street?: string - Street address

Usage:

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

const { addressJPSchema } = schemas;

const validate = ajv.compile(addressJPSchema as SchemaDefinition);
const isValid = validate({
city: 'Tokyo',
country: 'Japan',
postalCode: '100-0001',
prefecture: 'Tokyo',
street: '1-1-1 Chiyoda'
});

addressSchema​

Address information schema for standardized address validation.

Purpose: Validates complete address information with US postal code format

Schema Details:

  • Type: object
  • Additional Properties: false (strict validation)
  • Required Fields: street, city, state, country, postal_code
  • Properties:
    • street: string - Street address
    • city: string - City name
    • state: string - State or province
    • country: string - Country name
    • postal_code: string - Postal code (US format: 12345 or 12345-6789)

Usage:

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

const { addressSchema } = schemas;

const validate = ajv.compile(addressSchema.schemas as SchemaDefinition);
const isValid = validate({
street: '123 Main Street',
city: 'New York',
state: 'NY',
country: 'USA',
postal_code: '10001'
});