UNPKG

@ivandt/json-rules

Version:

Rule parsing engine for JSON rules

40 lines (39 loc) 1.38 kB
export interface TemplateVariable { name: string; fullMatch: string; startIndex: number; endIndex: number; } export declare class TemplateParser { #private; private readonly TEMPLATE_REGEX; /** * Checks if a value contains template syntax * @param value The value to check * @returns True if value contains template variables */ hasTemplateVariables(value: any): boolean; /** * Extracts all template variables from a value * @param value The value to parse * @returns Array of template variables found */ extractTemplateVariables(value: any): TemplateVariable[]; /** * Resolves template variables in a value using provided criteria * @param value The value containing templates * @param criteria The criteria object to resolve field references from * @returns The resolved value with templates replaced */ resolveTemplateValue(value: any, criteria: object): any; /** * Validates that all template variables in a value exist in the criteria * @param value The value containing templates * @param criteria The criteria object to validate against * @returns Object with validation result and missing fields */ validateTemplateVariables(value: any, criteria: object): { isValid: boolean; missingFields: string[]; }; }