mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 19:45:09 +08:00
# Conflicts: # jsowell-ui/.env.development # jsowell-ui/.env.staging # jsowell-ui/bin/build-sit.bat # jsowell-ui/bin/build.bat # jsowell-ui/src/api/adapayMember/adapayMember.js # jsowell-ui/src/api/pile/merchant.js # jsowell-ui/src/router/index.js # jsowell-ui/src/views/financial/financeDetail.vue # jsowell-ui/src/views/financial/merchant.vue # jsowell-ui/src/views/homeIndex/homeIndex.vue # jsowell-ui/src/views/login.vue # jsowell-ui/src/views/pile/basic/detail.vue # jsowell-ui/src/views/pile/station/components/SiteInfo.vue # jsowell-ui/src/views/pile/station/detail.vue # jsowell-ui/src/views/pile/station/orderReport.vue
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.OptionValidator = void 0;
|
|
var _findSuggestion = require("./find-suggestion.js");
|
|
class OptionValidator {
|
|
constructor(descriptor) {
|
|
this.descriptor = descriptor;
|
|
}
|
|
validateTopLevelOptions(options, TopLevelOptionShape) {
|
|
const validOptionNames = Object.keys(TopLevelOptionShape);
|
|
for (const option of Object.keys(options)) {
|
|
if (!validOptionNames.includes(option)) {
|
|
throw new Error(this.formatMessage(`'${option}' is not a valid top-level option.
|
|
- Did you mean '${(0, _findSuggestion.findSuggestion)(option, validOptionNames)}'?`));
|
|
}
|
|
}
|
|
}
|
|
validateBooleanOption(name, value, defaultValue) {
|
|
if (value === undefined) {
|
|
return defaultValue;
|
|
} else {
|
|
this.invariant(typeof value === "boolean", `'${name}' option must be a boolean.`);
|
|
}
|
|
return value;
|
|
}
|
|
validateStringOption(name, value, defaultValue) {
|
|
if (value === undefined) {
|
|
return defaultValue;
|
|
} else {
|
|
this.invariant(typeof value === "string", `'${name}' option must be a string.`);
|
|
}
|
|
return value;
|
|
}
|
|
invariant(condition, message) {
|
|
if (!condition) {
|
|
throw new Error(this.formatMessage(message));
|
|
}
|
|
}
|
|
formatMessage(message) {
|
|
return `${this.descriptor}: ${message}`;
|
|
}
|
|
}
|
|
exports.OptionValidator = OptionValidator;
|
|
|
|
//# sourceMappingURL=validator.js.map
|