2019-10-31 11:43:04 +00:00
|
|
|
const Vue = require('vue');
|
|
|
|
const validator = {
|
|
|
|
created() {
|
|
|
|
const props = this.$options.props;
|
|
|
|
const invalidProps = [];
|
|
|
|
|
2022-10-04 11:41:37 +00:00
|
|
|
for (const prop in props) {
|
2019-10-31 11:43:04 +00:00
|
|
|
const isObject = typeof props[prop] === 'object';
|
|
|
|
const isRequired = props[prop].required;
|
|
|
|
const isNotDefined = this[prop] === undefined;
|
|
|
|
|
|
|
|
if (isObject && isRequired && isNotDefined)
|
|
|
|
invalidProps.push(prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (invalidProps.length > 0) {
|
|
|
|
const required = invalidProps.join(', ');
|
|
|
|
|
2019-11-19 09:32:09 +00:00
|
|
|
throw new Error(`Required properties not found [${required}]`);
|
2019-10-31 11:43:04 +00:00
|
|
|
}
|
|
|
|
},
|
2022-10-04 11:41:37 +00:00
|
|
|
props: ['isPreview', 'access_token']
|
2019-10-31 11:43:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Vue.mixin(validator);
|