object-to-schema
Advanced tools
Comparing version 1.3.2 to 1.4.0
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="1.4.0"></a> | ||
# [1.4.0](https://github.com/forsigner/object-to-schema/compare/v1.3.2...v1.4.0) (2017-12-29) | ||
### Features | ||
* use new seperator ([10e7559](https://github.com/forsigner/object-to-schema/commit/10e7559)) | ||
<a name="1.3.2"></a> | ||
@@ -7,0 +17,0 @@ ## [1.3.2](https://github.com/forsigner/object-to-schema/compare/v1.3.1...v1.3.2) (2017-12-28) |
@@ -6,3 +6,3 @@ 'use strict'; | ||
const obj = { | ||
'// name': [ null, [ '// user name' ]], | ||
'// name': [ null, [ '// user name|maxLength:10' ]], | ||
name: 'Tom', | ||
@@ -9,0 +9,0 @@ times: [ 1, 2, 3 ], |
@@ -9,2 +9,3 @@ 'use strict'; | ||
var _ = require('lodash'); | ||
var separator = '(@#$%)'; | ||
module.exports = objectToSchema; | ||
@@ -75,3 +76,4 @@ | ||
var desc = getDesc(object['// ' + item]); | ||
obj[item] = makeSchema(object[item] + '|' + type + '|' + desc); | ||
var value = '' + object[item] + separator + type + separator + desc; | ||
obj[item] = makeSchema(value); | ||
} else { | ||
@@ -104,2 +106,3 @@ obj[item] = makeSchema(object[item]); | ||
if (!_.isArray(comment) || _.isEmpty(comment)) return ''; | ||
return (comment[1] || '').toString().replace(/^\/\//, '').trim(); | ||
@@ -149,3 +152,3 @@ } | ||
} | ||
var arr = value.split('|'); | ||
var arr = value.split(separator); | ||
if (arr.length < 2) { | ||
@@ -152,0 +155,0 @@ return { type: type, default: value }; |
{ | ||
"name": "object-to-schema", | ||
"description": "", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"main": "lib/index.js", | ||
@@ -6,0 +6,0 @@ "author": { |
12235
263