pip-services3-commons-nodex
Version:
Portable abstractions and patterns for Pip.Services in Node.js / ES2017
90 lines • 2.38 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValidationResult = void 0;
/**
* Result generated by schema validation
*/
class ValidationResult {
/**
* Creates a new instance of validation ressult and sets its values.
*
* @param path a dot notation path of the validated element.
* @param type a type of the validation result: Information, Warning, or Error.
* @param code an error code.
* @param message a human readable message.
* @param expected an value expected by schema validation.
* @param actual an actual value found by schema validation.
*
* @see [[ValidationResultType]]
*/
constructor(path = null, type = null, code = null, message = null, expected = null, actual = null) {
this._path = path;
this._type = type;
this._code = code;
this._message = message;
this._expected = expected;
this._actual = actual;
}
/**
* Gets dot notation path of the validated element.
*
* @returns the path of the validated element.
*/
getPath() {
return this._path;
}
/**
* Gets the type of the validation result: Information, Warning, or Error.
*
* @returns the type of the validation result.
*
* @see [[ValidationResultType]]
*/
getType() {
return this._type;
}
/**
* Gets the error code.
*
* @returns the error code
*/
getCode() {
return this._code;
}
/**
* Gets the human readable message.
*
* @returns the result message.
*/
getMessage() {
return this._message;
}
/**
* Gets the value expected by schema validation.
*
* @returns the expected value.
*/
getExpected() {
return this._expected;
}
/**
* Gets the actual value found by schema validation.
*
* @returns the actual value.
*/
getActual() {
return this._actual;
}
toJSON() {
return {
path: this._path,
type: this._type,
code: this._code,
message: this._message,
expected: this._expected,
actual: this._actual
};
}
}
exports.ValidationResult = ValidationResult;
//# sourceMappingURL=ValidationResult.js.map