Transformation that validates rules for DNS blockers. Uses AGTree for robust parsing and validation. Removes invalid rules and their preceding comments.
ValidateTransformation(allowIp?: boolean,logger?: ILogger,)
Creates a new ValidateTransformation
name: string
Human-readable name of the transformation
type: TransformationType
The transformation type identifier
allowIp: boolean
Whether IP addresses are allowed in rules
currentSourceName: string
Current source name for error tracking
lastValidationReport: IValidationReport | null
Last validation report (from most recent executeSync call)
addValidationError(errors: IValidationError[],type: ValidationErrorType,severity: ValidationSeverity,ruleText: string,message: string,details?: string,ast?: AnyRule,lineNumber?: number,): void
Add a validation error to the provided errors array
executeSync(rules: string[]): string[]
Executes the validation transformation synchronously.
getValidationReport(): IValidationReport | null
Get the validation report from the most recent executeSync call
isCommentOrEmpty(ast: AnyRule | null,ruleText: string,): boolean
Check if the parsed rule is a comment or empty.
isValidParsedRule(): boolean
Validates a parsed rule using the AST.
setSourceName(sourceName: string | undefined): void
Set the current source name for error tracking
validateHostRule(): boolean
Validates a /etc/hosts rule using AGTree AST.
validateHostname(hostname: string,ruleText: string,hasLimitModifier: boolean,lineNumber: number | undefined,errors: IValidationError[],): boolean
Validates a hostname for the blocklist.
validateNetworkRule(): boolean
Validates an adblock-style network rule using AGTree AST.