Merge pull request #1086 from jameslcj/feature/yaml
feature: add yaml validator #1084
This commit is contained in:
commit
696312a33c
@ -38,6 +38,9 @@ module.exports = {
|
||||
components: resolve('src/components'),
|
||||
},
|
||||
},
|
||||
node: {
|
||||
fs: 'empty'
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
|
@ -75,6 +75,7 @@
|
||||
"react-router-dom": "^4.3.1",
|
||||
"react-router-redux": "^4.0.8",
|
||||
"redux": "^4.0.1",
|
||||
"redux-thunk": "^2.3.0"
|
||||
"redux-thunk": "^2.3.0",
|
||||
"yamljs": "^0.3.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
import * as yamljs from 'yamljs';
|
||||
|
||||
export default {
|
||||
/**
|
||||
* 检测json是否合法
|
||||
@ -35,15 +37,13 @@ export default {
|
||||
/**
|
||||
* 检测yaml是否合法
|
||||
*/
|
||||
// validateYaml(str) {
|
||||
// try {
|
||||
// console.log('yaml: ', yaml, yaml.safeLoadAll(str));
|
||||
// return !!yaml.safeLoadAll(str);
|
||||
// } catch (e) {
|
||||
// console.log('e: ', e);
|
||||
// return false;
|
||||
// }
|
||||
// },
|
||||
validateYaml(str) {
|
||||
try {
|
||||
return yamljs.parse(str);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 检测属性是否正确
|
||||
@ -66,6 +66,7 @@ export default {
|
||||
'text/html': this.validateXml,
|
||||
html: this.validateXml,
|
||||
properties: this.validateProperties,
|
||||
yaml: this.validateYaml,
|
||||
};
|
||||
|
||||
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
Loading…
Reference in New Issue
Block a user