avo-inspector
Version:
[](https://badge.fury.io/js/avo-inspector)
35 lines (34 loc) • 1.5 kB
TypeScript
/**
* EventValidator - Client-side validation of tracking events against the Avo Tracking Plan.
*
* This module validates property values against constraints:
* - Pinned values (exact match required)
* - Allowed values (must be in list)
* - Regex patterns (must match pattern)
* - Min/max ranges (numeric values must be in range)
*
* No schema validation (types/required) is performed - only value constraints.
* Validation runs against ALL events/variants in the response.
*/
import type { EventSpecResponse, ValidationResult } from "./AvoEventSpecFetchTypes";
/**
* Runtime property value - can be any JSON-compatible type
*/
export type RuntimePropertyValue = string | number | boolean | null | undefined | object | Array<any>;
/**
* Runtime properties map
*/
export type RuntimeProperties = Record<string, RuntimePropertyValue>;
/**
* Validates runtime properties against all events in the EventSpecResponse.
*
* For each property:
* - If property not in spec: no validation needed (empty result)
* - If property in spec: check constraints and collect failed/passed eventIds
* - Return whichever list is smaller for bandwidth optimization
*
* @param properties - The properties observed at runtime
* @param specResponse - The EventSpecResponse from the backend
* @returns ValidationResult with baseEventId, metadata, and per-property results
*/
export declare function validateEvent(properties: RuntimeProperties, specResponse: EventSpecResponse): ValidationResult;