import { CombinedAllNodeVisitor } from '../../combined/visitors/CombinedAllNodeVisitor'; import { Node } from '../models/Node'; import { IVisitor } from '../visitors/IVisitor'; /** * Constructor. * @param {ValidationRuleMetaData} ruleInfo * @class * @extends CombinedAllNodeVisitor * @author eric.wittmann@gmail.com */ export declare abstract class ValidationRule extends CombinedAllNodeVisitor implements IVisitor { /** * List of valid HTTP response status codes from: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml */ static HTTP_STATUS_CODES: Array; static PATH_MATCH_REGEX: string; static SEG_MATCH_REGEX: string; static URL_MATCH_REGEX: string; static EMAIL_MATCH_REGEX: string; static MIME_TYPE_MATCH_REGEX: string; reporter: IValidationProblemReporter; ruleInfo: ValidationRuleMetaData; constructor(ruleInfo: ValidationRuleMetaData); /** * Sets the validation problem reporter. * @param {*} reporter */ setReporter(reporter: IValidationProblemReporter): void; /** * Called by validation rules to report an error. * @param {Node} node * @param {string} property * @param {*} messageParams */ report(node: Node, property: string, messageParams: any): void; /** * Creates a message from a template and set of params. * @param {string} messageTemplate * @param {*} messageParams * @return {string} * @private */ resolveMessage(messageTemplate: string, messageParams: any): string; /** * Reports a validation error if the property is not valid. * @param {boolean} isValid * @param {Node} node * @param {string} property * @param {*} messageParams */ reportIfInvalid(isValid: boolean, node: Node, property: string, messageParams: any): void; /** * Reports a validation error if the given condition is true. * @param {boolean} condition * @param {Node} node * @param {string} property * @param {*} messageParams */ reportIf(condition: boolean, node: Node, property: string, messageParams: any): void; /** * Utility function to report path related errors. * @param {Node} node * @param {*} messageParams */ reportPathError(node: Node, messageParams: any): void; /** * Check if a property was defined. * @param {*} propertyValue * @return {boolean} {boolean} */ isDefined(propertyValue: any): boolean; /** * Check if the property value exists (is not undefined and is not null). * @param {*} propertyValue * @return {boolean} {boolean} */ hasValue(propertyValue: any): boolean; /** * Checks the path template against the regular expression and returns match result. * * @param {string} pathTemplate * @return {boolean} {boolean} */ isPathWellFormed(pathTemplate: string): boolean; /** * Finds all occurences of path segment patterns in a path template. * * @param {string} pathTemplate * @return {ValidationRule.PathSegment[]} {PathSegment[]} */ getPathSegments(pathTemplate: string): Array; /** * Check if a value is either null or undefined. * @param {*} value * @return {boolean} {boolean} */ isNullOrUndefined(value: any): boolean; /** * Returns true only if the given value is a valid URL. * @param {string} propertyValue * @return {boolean} {boolean} */ isValidUrl(propertyValue: string): boolean; /** * Returns true only if the given value is a valid URL template. * @param {string} propertyValue * @return {boolean} */ isValidUrlTemplate(propertyValue: string): boolean; /** * Returns true only if the given value is valid GFM style markup. * @param {string} propertyValue * @return {boolean} */ isValidGFM(propertyValue: string): boolean; /** * Returns true only if the given value is valid CommonMark style markup. * @param {string} propertyValue * @return {boolean} */ isValidCommonMark(propertyValue: string): boolean; /** * Returns true only if the given value is a valid email address. * @param {string} propertyValue * @return {boolean} */ isValidEmailAddress(propertyValue: string): boolean; /** * Returns true only if the given value is a valid mime-type. * @param {string[]} propertyValue * @return {boolean} */ isValidMimeType(propertyValue: Array): boolean; /** * Returns true if the given value is an item in the enum list. * @param {string} value * @param {Array} items * @return {boolean} */ isValidEnumItem(value: string, items: string[]): boolean; /** * Returns true if the given value is valid according to the schema provided. * @param {*} value * @param {Node} node * @return {boolean} */ isValidForType(value: any, node: Node): boolean; /** * Returns true if the given status code is a valid HTTP response code. * @param {string} statusCode * @return {boolean} */ isValidHttpCode(statusCode: string): boolean; /** * Turns a list of args into a map suitable for use as template arguments. The args must come * in pairs of "key, value". For example: * * map("key1", "value1", "key2", Boolean.TRUE); * * That would return a {@link Map} two mappings. * @param {Array} args * @return {*} */ map(...args: string[]): any; /** * Creates an array. * @param {Array} args * @return {Array} */ array(...args: string[]): string[]; /** * Returns true if the two values are equal. * @param {*} value1 * @param {*} value2 * @return {boolean} */ equals(value1: any, value2: any): boolean; } export declare namespace ValidationRule { /** * Type encapsulating information about a path segment. * Consumers of this type should not rely on normalizedName property which is only provided to weed out duplicates. * @class */ class PathSegment { segId: number; prefix: string; formalName: string; normalizedName: string; constructor(); } } import { ValidationRuleMetaData } from './ValidationRuleMetaData'; import { IValidationProblemReporter } from './IValidationProblemReporter';