@revrag-ai/embed-react-native
Version:
A powerful React Native library for integrating AI-powered voice agents into mobile applications. Features real-time voice communication, intelligent speech processing, customizable UI components, and comprehensive event handling for building conversation
36 lines (33 loc) • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.validateAnalyticsEvent = validateAnalyticsEvent;
exports.validateEventKey = validateEventKey;
var _embedTypes = require("./embed.types.js");
/**
* Validation helpers for Embed events
*/
/**
* Validates event key is valid
* @param eventKey - The event key to validate
* @throws Error if event key is invalid
*/
function validateEventKey(eventKey) {
if (!Object.values(_embedTypes.EventKeys).includes(eventKey)) {
throw new Error(`Invalid event key: ${eventKey}. Must be one of: ${Object.values(_embedTypes.EventKeys).join(', ')}`);
}
}
/**
* Validates analytics events have required event_name
* @param paramsData - The event payload to validate
* @throws Error if analytics event is missing event_name
*/
function validateAnalyticsEvent(paramsData) {
if (paramsData.type === 'analytics_data') {
if (!paramsData.event_name || paramsData.event_name.trim() === '') {
throw new Error(`Analytics event requires an event_name. Please provide event_name in the data payload.`);
}
}
}
//# sourceMappingURL=embed.validators.js.map