Skip to content

Commit 45cbbb5

Browse files
committed
fix: revert validate option
1 parent 0d47cd8 commit 45cbbb5

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Options include:
6363
buffer: false, // set to true if you are parsing from buffers instead of strings
6464
required: false, // set to true if all properties are required
6565
ordered: false, // set to true if your properties have the same order always
66+
validate: true, // set to false to disable extra type validation
6667
validateStrings: true, // set to false to disable extra type validation
6768
fullMatch: true, // set to false to do fastest match based on the schema (unsafe!)
6869
unescapeStrings: true, // set to false if you don't need to unescape \ chars

lib/object.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function defaults (opts) {
1111

1212
const allowEmptyObjects = opts.allowEmptyObjects !== false
1313
const required = !!opts.allRequired
14+
const validate = opts.validate !== false
1415
const ordered = !!opts.ordered
1516
const fullMatch = opts.fullMatch !== false
1617
const defaults = opts.defaults !== false
@@ -22,7 +23,7 @@ function defaults (opts) {
2223
class Required {
2324
constructor (gen, o, fields) {
2425
this.name = o + 'Required'
25-
this.fields = fields.filter(isRequired)
26+
this.fields = validate ? fields.filter(isRequired) : []
2627
this.count = this.fields.length
2728
this.gen = gen
2829
this.vars = []

types.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ interface ITurboJsonConfig {
22
buffer: boolean;
33
required:boolean;
44
ordered: boolean;
5+
validate: boolean;
56
validateStrings: boolean;
67
fullMatch: boolean;
78
unescapeStrings: boolean;

0 commit comments

Comments
 (0)