test-openapi
Version:
Automated client requests
50 lines (36 loc) • 905 B
JavaScript
;Object.defineProperty(exports,"__esModule",{value:true});exports.checkRequired=void 0;var _error=require("../../../errors/error.js");
const checkRequired=function({
schema,
schema:{
"x-optional":isOptional=false,
"x-forbidden":isForbidden=false},
value,
property,
name})
{
if(isForbidden){
return validateForbidden({schema,value,property,name});
}
if(!isOptional){
return validateRequired({schema,value,property,name});
}
};exports.checkRequired=checkRequired;
const validateForbidden=function({schema,value,property,name}){
if(value===undefined){
return;
}
throw new _error.TestOpenApiError(`${name} should be empty`,{
property,
schema,
value});
};
const validateRequired=function({schema,value,property,name}){
if(value!==undefined){
return;
}
throw new _error.TestOpenApiError(`${name} should not be empty`,{
property,
schema,
value});
};
//# sourceMappingURL=required.js.map