object-to-schema
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="1.5.0"></a> | ||
# [1.5.0](https://github.com/forsigner/object-to-schema/compare/v1.4.0...v1.5.0) (2017-12-29) | ||
### Features | ||
* update comment format ([09b59a1](https://github.com/forsigner/object-to-schema/commit/09b59a1)) | ||
<a name="1.4.0"></a> | ||
@@ -7,0 +17,0 @@ # [1.4.0](https://github.com/forsigner/object-to-schema/compare/v1.3.2...v1.4.0) (2017-12-29) |
@@ -6,3 +6,3 @@ 'use strict'; | ||
const obj = { | ||
'// name': [ null, [ '// user name|maxLength:10' ]], | ||
'// name': 'user name|maxLength:10', | ||
name: 'Tom', | ||
@@ -12,3 +12,3 @@ times: [ 1, 2, 3 ], | ||
user: { | ||
'// age': [ null, [ '// 年龄' ]], | ||
'// age': '年龄', | ||
age: 1, | ||
@@ -15,0 +15,0 @@ '// addr': '地址', |
@@ -74,3 +74,3 @@ 'use strict'; | ||
var type = typeOf(object[item]); | ||
var desc = getDesc(object['// ' + item]); | ||
var desc = object['// ' + item]; | ||
var value = '' + object[item] + separator + type + separator + desc; | ||
@@ -101,10 +101,2 @@ obj[item] = makeSchema(value); | ||
function getDesc() { | ||
var comment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
if (!_.isArray(comment) || _.isEmpty(comment)) return ''; | ||
return (comment[1] || '').toString().replace(/^\/\//, '').trim(); | ||
} | ||
function objectToSchema(data) { | ||
@@ -111,0 +103,0 @@ var _iteratorNormalCompletion2 = true; |
{ | ||
"name": "object-to-schema", | ||
"description": "", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"main": "lib/index.js", | ||
@@ -6,0 +6,0 @@ "author": { |
12184
258