fastman
Version:
快速api测试及文档生成
99 lines • 3.6 kB
JavaScript
;
/**
* @license
* Copyright 2017 Red Hat
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var visitor_base_1 = require("../../visitors/visitor.base");
var validation_1 = require("../validation");
/**
* Base class for all 3.0 validation rules.
*/
var Oas30ValidationRule = /** @class */ (function (_super) {
__extends(Oas30ValidationRule, _super);
function Oas30ValidationRule(reporter) {
var _this = _super.call(this) || this;
_this._reporter = reporter;
return _this;
}
/**
* Reports a validation error if the property is not valid.
* @param code
* @param condition
* @param node
* @param message
*/
Oas30ValidationRule.prototype.reportIf = function (code, condition, node, message) {
if (condition) {
this.report(code, node, message);
}
};
/**
* Reports a validation error if the property is not valid.
* @param code
* @param isValid
* @param node
* @param message
*/
Oas30ValidationRule.prototype.reportIfInvalid = function (code, isValid, node, message) {
this.reportIf(code, !isValid, node, message);
};
/**
* Check if a property was defined.
* @param propertyValue
* @return {boolean}
*/
Oas30ValidationRule.prototype.isDefined = function (propertyValue) {
return validation_1.OasValidationRuleUtil.isDefined(propertyValue);
};
/**
* Check if a value is either null or undefined.
* @param value
* @return {boolean}
*/
Oas30ValidationRule.prototype.isNullOrUndefined = function (value) {
return value === null || value === undefined;
};
/**
* Check if the property value exists (is not undefined and is not null).
* @param propertyValue
* @return {boolean}
*/
Oas30ValidationRule.prototype.hasValue = function (propertyValue) {
return validation_1.OasValidationRuleUtil.hasValue(propertyValue);
};
/**
* Called by validation rules to report an error.
* @param code
* @param node
* @param message
*/
Oas30ValidationRule.prototype.report = function (code, node, message) {
this._reporter.report(code, node, message);
};
return Oas30ValidationRule;
}(visitor_base_1.Oas30NodeVisitorAdapter));
exports.Oas30ValidationRule = Oas30ValidationRule;
//# sourceMappingURL=common.rule.js.map