UNPKG

amazon-route-53-dns-zone-file

Version:

Makes DNS Zone File easy. Parses and validates BIND zone files and can be extended for custom features. Functionality is modular. Features are made open for extension and closed for runtime mutation. Written in TypeScript.

40 lines (34 loc) 1.14 kB
import { ParsingError } from '../errors/parsing_error'; import { SourceMapTypings, ParserTypings } from '../parser/types_parser'; import { Validation } from './validation_types'; export class ErrorBuilder implements Validation.ValidationErrorBuilder { public parsingLineNumber: number = 0; public entry: SourceMapTypings.Value = undefined as any; public getErrorText: Validation.GetErrorTextFn = undefined as any; public update( parsingLineNumber: number, entry: SourceMapTypings.Value ): this { this.parsingLineNumber = parsingLineNumber; this.entry = entry; return this; } public create<Overrides extends Partial<ParserTypings.MetaArg>>( overrides?: Overrides, i18nArgs?: Validation.I18nRenderObj ): ParsingError { const args = { parsingLineNumber: this.parsingLineNumber as number, ...this.entry!, ...overrides, } as Validation.ErrorEntry; const i18nMessage = this.getErrorText(args, i18nArgs); return new ParsingError( i18nMessage, args.instructionType as any, args.parsingLineNumber, args.lineContent, args.value ); } }