@atlasrender/render-plugin
Version:
Atlas Render Farm Manager plugin system.
108 lines (107 loc) • 3.54 kB
TypeScript
import ValidatorOptionsExtended from "../interfaces/ValidatorOptionsExtended";
import Validator from "./Validator";
import { ValidationErrorOptions } from "../interfaces";
import WebJsonable from "../interfaces/WebJsonable";
/**
* ValidationError - validation error for plugin setting.
* @class
* @author Danil Andreev
*/
export default class ValidationError extends TypeError implements WebJsonable {
/**
* validation - validation map.
*/
protected validation: Validator[];
/**
* fatalError - if true, validation of this token is failed with fatal error.
* @protected
*/
protected fatalError: boolean;
/**
* nested - nested errors.
* @protected
*/
protected nested: ValidationError[];
/**
* id - custom identifier. Not used in validation.
*/
readonly id?: string | number;
/**
* Creates an instance of SettingsValidationError
* @param message - String message.
* @param validation - Validation map object.
* @param options - Validation error additional options.
* @author Danil Andreev
*/
constructor(message: string, validation?: Validator[], options?: ValidationErrorOptions);
/**
* createValidationError - creates ValidationError instance from input structure.
* @method
* @param input - Any input data. Will be checked and validated.
* @throws TypeError
* @author Danil Andreev
*/
static createValidationError(input: any): ValidationError;
/**
* getValidation - method for getting validation map from error.
* @method
* @author Danil Andreev
*/
getValidation(): readonly Validator[];
/**
* getNested - method for getting nested errors.
* @method
* @author Danil Andreev
*/
getNested(): readonly ValidationError[];
/**
* failValidation - function, designed to fail validation with fatal error.
* @method
* @author Danil Andreev
*/
failValidation(): ValidationError;
/**
* isFatal - if validation failed with fatal error - returns true, else - false.
* @method
* @author Danil Andreev
*/
isFatal(): boolean;
/**
* hasErrors - method, designed to check if this error has validators.
* @method
* @author Danil Andreev
*/
hasErrors(): boolean;
/**
* errorOn - returns error if it is error on selected field or undefined if not.
* @method
* @param key - Key of the field.
* @author Danil Andreev
*/
errorOn(key: string): Validator | undefined;
/**
* reject - method, designed to allow setting element rejection.
* @method
* @param name - The key of an element in setting.
* @param expected - Expected value of an element.
* @param options - Options for more detailed setup.
* @author Danil Andreev
*/
reject(name: string, expected: string, options?: ValidatorOptionsExtended): ValidationError;
addNested(error: ValidationError | ValidationError[]): ValidationError;
getJSON(): object;
/**
* getFlatErrorsList - returns flatten errors list with all nested errors and errors nested in validators.
* @method
* @author Danil Andreev
*/
getFlatErrorsList(): ValidationError[];
/**
* getErrorOnId - returns error with custom id that matches input id.
* If not found - returns false.
* @method
* @param id - Target id.
* @author Danil Adnreev
*/
getErrorOnId(id: number | string): ValidationError;
}