fast-json-stringify
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -19,4 +19,3 @@ 'use strict' | ||
now: { | ||
type: 'string', | ||
required: true | ||
type: 'string' | ||
}, | ||
@@ -26,3 +25,4 @@ reg: { | ||
} | ||
} | ||
}, | ||
required: ['now'] | ||
}) | ||
@@ -29,0 +29,0 @@ |
@@ -161,3 +161,3 @@ 'use strict' | ||
if (schema.properties[key].required) { | ||
if (schema.required && schema.required.indexOf(key) !== -1) { | ||
code += ` | ||
@@ -164,0 +164,0 @@ } else { |
{ | ||
"name": "fast-json-stringify", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Stringify your JSON at max speed", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -72,9 +72,9 @@ # fast-json-stringify [![Build Status](https://travis-ci.org/mcollina/fast-json-stringify.svg)](https://travis-ci.org/mcollina/fast-json-stringify) | ||
| Instance | Serialized as | | ||
| -----------|---------------------------------------------| | ||
| Instance | Serialized as | | ||
| -----------|------------------------------| | ||
| `Date` | `string` via `toISOString()` | | ||
| `RegExp` | `string` | | ||
| `RegExp` | `string` | | ||
#### Required | ||
You can set specific fields of an object as `required` in your schema, by adding `required: true` inside the key properties. | ||
You can set specific fields of an object as required in your schema, by adding the field name inside the `required` array in your schema. | ||
Example: | ||
@@ -90,6 +90,6 @@ ```javascript | ||
mail: { | ||
type: 'string', | ||
required: true | ||
type: 'string' | ||
} | ||
} | ||
}, | ||
required: ['mail'] | ||
} | ||
@@ -96,0 +96,0 @@ ``` |
@@ -266,4 +266,3 @@ 'use strict' | ||
str: { | ||
type: 'string', | ||
required: true | ||
type: 'string' | ||
}, | ||
@@ -273,3 +272,4 @@ num: { | ||
} | ||
} | ||
}, | ||
required: ['str'] | ||
} | ||
@@ -276,0 +276,0 @@ const stringify = build(schema) |
18365