40 lines
1.5 KiB
JavaScript
40 lines
1.5 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const types_1 = require("oak-domain/lib/types");
|
|
const validator_1 = require("oak-domain/lib/utils/validator");
|
|
const version_1 = require("oak-domain/lib/utils/version");
|
|
const checkers = [
|
|
{
|
|
type: 'data',
|
|
action: 'create',
|
|
entity: 'platform',
|
|
checker: (data) => {
|
|
const setData = (data) => {
|
|
if (!data.config) {
|
|
Object.assign(data, {
|
|
config: {},
|
|
});
|
|
}
|
|
};
|
|
if (data instanceof Array) {
|
|
data.forEach((ele) => {
|
|
(0, validator_1.checkAttributesNotNull)('platform', ele, ['name']);
|
|
if (ele.oldestVersion && !(0, version_1.isVersion)(ele.oldestVersion)) {
|
|
throw new types_1.OakInputIllegalException('system', ['oldestVersion'], 'error::illegalVersionData', 'oak-general-business');
|
|
}
|
|
setData(ele);
|
|
});
|
|
}
|
|
else {
|
|
(0, validator_1.checkAttributesNotNull)('platform', data, ['name']);
|
|
if (data.oldestVersion && !(0, version_1.isVersion)(data.oldestVersion)) {
|
|
throw new types_1.OakInputIllegalException('system', ['oldestVersion'], 'error::illegalVersionData', 'oak-general-business');
|
|
}
|
|
setData(data);
|
|
}
|
|
return;
|
|
},
|
|
},
|
|
];
|
|
exports.default = checkers;
|