26 lines
714 B
JavaScript
26 lines
714 B
JavaScript
const Vue = require('vue');
|
|
const validator = {
|
|
created() {
|
|
const props = this.$options.props;
|
|
const invalidProps = [];
|
|
|
|
for (const prop in props) {
|
|
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(', ');
|
|
|
|
throw new Error(`Required properties not found [${required}]`);
|
|
}
|
|
},
|
|
props: ['isPreview', 'access_token']
|
|
};
|
|
|
|
Vue.mixin(validator);
|