优化回调参数

This commit is contained in:
Harvey Zack committed 2019-04-22 13:32:27 +08:00
1 parent 2385128abb
commit 62c05ef659
5 files changed
+44 -31

No files matched your search

+17 -1
View File
@@ -1,4 +1,20 @@
import validElement from './validElement';
import { ArtPlayerError } from '../utils';
function validElement(paths, value, type) {
if (type === 'string') {
if (value.trim() === '') {
throw new ArtPlayerError(`${paths.join('.')} can not be empty`);
} else {
return true;
}
}
if (value instanceof Element) {
return true;
}
throw new ArtPlayerError(`${paths.join('.')} require 'string' or 'Element' type, but got '${type}'`);
}
export default {
container: {
@@ -1,17 +0,0 @@
import { ArtPlayerError } from '../utils';
export default function validElement(paths, value, type) {
if (type === 'string') {
if (value.trim() === '') {
throw new ArtPlayerError(`${paths.join('.')} can not be empty`);
} else {
return true;
}
}
if (value instanceof Element) {
return true;
}
throw new ArtPlayerError(`${paths.join('.')} require 'string' or 'Element' type, but got '${type}'`);
}