Merge pull request #1086 from jameslcj/feature/yaml

feature: add yaml validator #1084
This commit is contained in:
Fury Zhu 2019-06-10 16:57:11 +08:00 committed by GitHub
commit 696312a33c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 20 deletions

View File

@ -38,6 +38,9 @@ module.exports = {
components: resolve('src/components'), components: resolve('src/components'),
}, },
}, },
node: {
fs: 'empty'
},
module: { module: {
rules: [ rules: [
{ {

View File

@ -75,6 +75,7 @@
"react-router-dom": "^4.3.1", "react-router-dom": "^4.3.1",
"react-router-redux": "^4.0.8", "react-router-redux": "^4.0.8",
"redux": "^4.0.1", "redux": "^4.0.1",
"redux-thunk": "^2.3.0" "redux-thunk": "^2.3.0",
"yamljs": "^0.3.0"
} }
} }

View File

@ -1,3 +1,5 @@
import * as yamljs from 'yamljs';
export default { export default {
/** /**
* 检测json是否合法 * 检测json是否合法
@ -35,15 +37,13 @@ export default {
/** /**
* 检测yaml是否合法 * 检测yaml是否合法
*/ */
// validateYaml(str) { validateYaml(str) {
// try { try {
// console.log('yaml: ', yaml, yaml.safeLoadAll(str)); return yamljs.parse(str);
// return !!yaml.safeLoadAll(str); } catch (e) {
// } catch (e) { return false;
// console.log('e: ', e); }
// return false; },
// }
// },
/** /**
* 检测属性是否正确 * 检测属性是否正确
@ -66,6 +66,7 @@ export default {
'text/html': this.validateXml, 'text/html': this.validateXml,
html: this.validateXml, html: this.validateXml,
properties: this.validateProperties, properties: this.validateProperties,
yaml: this.validateYaml,
}; };
if (!validateObj[type]) { if (!validateObj[type]) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long