@adguard/agtree
Version:
Tool set for working with adblock filter lists
40 lines (39 loc) • 1.72 kB
TypeScript
/**
* @file Validator for modifiers.
*/
import { type Modifier } from '../nodes/index.js';
import { type ValidationResult } from './helpers.js';
import { type AnyPlatform } from '../compatibility-tables/index.js';
/**
* Modifier validator class.
*/
declare class ModifierValidator {
/**
* Simply checks whether the modifier exists in any adblocker.
*
* **Deprecated** and **removed** modifiers are considered as **existent**.
*
* @param modifier Already parsed modifier AST node.
*
* @returns True if modifier exists, false otherwise.
*/
exists: (modifier: Modifier) => boolean;
/**
* Checks whether the given `modifier` is valid for specified `platforms`.
* It checks whether the modifier is supported by the product, deprecated, assignable, negatable, etc.
*
* @param platforms Platforms to check the modifier for. Can be a specific platform (e.g., AdgExtChrome)
* or a generic platform (e.g., AdgAny, UboExtChromium, or combination of multiple products).
* @param modifier Modifier AST node.
* @param isException Whether the modifier is used in exception rule, default to false.
* Needed to check whether the modifier is allowed only in blocking or exception rules.
*
* @note For single product: specific platforms use exact lookup, generic platforms use first match.
* If multiple products are specified (e.g., AdgAny | UboAny), validation is skipped and returns valid.
*
* @returns Result of modifier validation.
*/
validate: (platforms: AnyPlatform, modifier: Modifier, isException?: boolean) => ValidationResult;
}
export declare const modifierValidator: ModifierValidator;
export {};