mnotify-ts-sdk
Version:
Modern, zero-dependency TypeScript SDK for mNotify BMS API - Type-safe SMS, contacts, and account management with Railway-Oriented Programming
69 lines (68 loc) • 1.98 kB
TypeScript
/**
* Lightweight validation utilities for API responses
* Replaces heavy validation libraries with simple, focused validators
*/
export declare class ValidationError extends Error {
readonly field?: string | undefined;
constructor(message: string, field?: string | undefined);
}
/**
* Validates that a value is a string
*/
export declare const isString: (value: unknown) => value is string;
/**
* Validates that a value is a number
*/
export declare const isNumber: (value: unknown) => value is number;
/**
* Validates that a value is an array
*/
export declare const isArray: <T>(value: unknown) => value is T[];
/**
* Validates that a value is an object
*/
export declare const isObject: (value: unknown) => value is Record<string, unknown>;
/**
* Validates required fields in an object
*/
export declare function validateRequired(obj: unknown, fields: string[]): asserts obj is Record<string, unknown>;
/**
* Safe required-field validation that never throws.
* Useful inside type guards where throwing breaks Result flows.
*/
export declare const hasRequiredFields: (obj: unknown, fields: string[]) => obj is Record<string, unknown>;
/**
* Validates SMS send response
*/
export declare const validateSMSResponse: (data: unknown) => data is {
status: string;
code: string;
message: string;
summary: {
_id: string;
message_id: string;
type: string;
total_sent: number;
contacts: number;
total_rejected: number;
numbers_sent: string[];
credit_used: number;
credit_left: number;
};
};
/**
* Validates SMS delivery report response
*/
export declare const validateDeliveryReport: (data: unknown) => data is {
status: string;
report: Array<{
_id: number;
recipient: string;
message: string;
sender: string;
status: string;
date_sent: string;
campaign_id?: string;
retries: number;
}>;
};