New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

joi-to-json

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

joi-to-json - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

18

fixtures/joi-obj-12.1.0.js
const joi = require('joi-12')
const joiRequired = joi.defaults((schema) => schema.options({
presence: 'required'
}))
const joiAllowUnknown = joi.defaults((schema) => schema.options({
allowUnknown: true
}))
module.exports = joi.object().keys({

@@ -18,3 +25,3 @@ nickName: joi.string().required().example('鹄思乱想').description('Hero Nickname').min(3).max(20).regex(/^[a-z]+$/, { name: 'alpha', invert: true }),

level: joi.number().integer().min(10).max(100).default(50).multiple(10).example(10).description('Skill Level')
})
}).unknown(true)
).required()).min(1).max(3).unique().description('Skills'),

@@ -25,3 +32,10 @@ tags: joi.array().items(joi.string().required()).length(2),

notes: joi.any(),
facebookId: joi.string().allow(null)
facebookId: joi.string().allow(null),
meta: joiRequired.object().keys({
hash: joiRequired.string(),
optional: joiRequired.string().optional()
}),
nested: joiAllowUnknown.object().keys({
key: joiAllowUnknown.string()
})
})
const joi = require('joi-13')
const joiRequired = joi.defaults((schema) => schema.options({
presence: 'required'
}))
const joiAllowUnknown = joi.defaults((schema) => schema.options({
allowUnknown: true
}))
module.exports = joi.object().keys({

@@ -18,3 +25,3 @@ nickName: joi.string().required().example('鹄思乱想').description('Hero Nickname').min(3).max(20).regex(/^[a-z]+$/, { name: 'alpha', invert: true }),

level: joi.number().integer().min(10).max(100).default(50).multiple(10).example(10).description('Skill Level')
})
}).unknown(true)
).required()).min(1).max(3).unique().description('Skills'),

@@ -25,3 +32,10 @@ tags: joi.array().items(joi.string().required()).length(2),

notes: joi.any(),
facebookId: joi.string().allow(null)
facebookId: joi.string().allow(null),
meta: joiRequired.object().keys({
hash: joiRequired.string(),
optional: joiRequired.string().optional()
}),
nested: joiAllowUnknown.object().keys({
key: joiAllowUnknown.string()
})
})
const joi = require('joi-14')
const joiRequired = joi.defaults((schema) => schema.options({
presence: 'required'
}))
const joiAllowUnknown = joi.defaults((schema) => schema.options({
allowUnknown: true
}))
module.exports = joi.object().keys({

@@ -18,3 +25,3 @@ nickName: joi.string().required().example('鹄思乱想').description('Hero Nickname').min(3).max(20).regex(/^[a-z]+$/, { name: 'alpha', invert: true }),

level: joi.number().integer().min(10).max(100).default(50).multiple(10).example(10).description('Skill Level')
})
}).unknown(true)
).required()).min(1).max(3).unique().description('Skills'),

@@ -25,3 +32,10 @@ tags: joi.array().items(joi.string().required()).length(2),

notes: joi.any(),
facebookId: joi.string().allow(null)
facebookId: joi.string().allow(null),
meta: joiRequired.object().keys({
hash: joiRequired.string(),
optional: joiRequired.string().optional()
}),
nested: joiAllowUnknown.object().keys({
key: joiAllowUnknown.string()
})
})
const joi = require('joi-15')
const joiRequired = joi.defaults((schema) => schema.options({
presence: 'required'
}))
const joiAllowUnknown = joi.defaults((schema) => schema.options({
allowUnknown: true
}))
module.exports = joi.object().keys({

@@ -18,3 +25,3 @@ nickName: joi.string().required().example('鹄思乱想').description('Hero Nickname').min(3).max(20).regex(/^[a-z]+$/, { name: 'alpha', invert: true }),

level: joi.number().integer().min(10).max(100).default(50).multiple(10).example(10).description('Skill Level')
})
}).unknown(true)
).required()).min(1).max(3).unique().description('Skills'),

@@ -25,3 +32,10 @@ tags: joi.array().items(joi.string().required()).length(2),

notes: joi.any(),
facebookId: joi.string().allow(null)
facebookId: joi.string().allow(null),
meta: joiRequired.object().keys({
hash: joiRequired.string(),
optional: joiRequired.string().optional()
}),
nested: joiAllowUnknown.object().keys({
key: joiAllowUnknown.string()
})
})
const joi = require('joi-16')
const joiRequired = joi.defaults((schema) => schema.options({
presence: 'required'
}))
const joiAllowUnknown = joi.defaults((schema) => schema.options({
allowUnknown: true
}))
module.exports = joi.object().keys({

@@ -18,3 +25,3 @@ nickName: joi.string().required().example('鹄思乱想').description('Hero Nickname').min(3).max(20).pattern(/^[a-z]+$/, { name: 'alpha', invert: true }),

level: joi.number().integer().min(10).max(100).default(50).multiple(10).example(10).description('Skill Level')
})
}).unknown(true)
).required()).min(1).max(3).unique().description('Skills'),

@@ -25,3 +32,10 @@ tags: joi.array().items(joi.string().required()).length(2),

notes: joi.any(),
facebookId: joi.string().allow(null)
facebookId: joi.string().allow(null),
meta: joiRequired.object().keys({
hash: joiRequired.string(),
optional: joiRequired.string().optional()
}),
nested: joiAllowUnknown.object().keys({
key: joiAllowUnknown.string()
})
})
const joi = require('joi-17')
const joiRequired = joi.defaults((schema) => schema.options({
presence: 'required'
}))
const joiAllowUnknown = joi.defaults((schema) => schema.options({
allowUnknown: true
}))
module.exports = joi.object().keys({

@@ -18,3 +25,3 @@ nickName: joi.string().required().example('鹄思乱想').description('Hero Nickname').min(3).max(20).pattern(/^[a-z]+$/, { name: 'alpha', invert: true }),

level: joi.number().integer().min(10).max(100).default(50).multiple(10).example(10).description('Skill Level')
})
}).unknown(true)
).required()).min(1).max(3).unique().description('Skills'),

@@ -25,3 +32,10 @@ tags: joi.array().items(joi.string().required()).length(2),

notes: joi.any(),
facebookId: joi.string().allow(null)
facebookId: joi.string().allow(null),
meta: joiRequired.object().keys({
hash: joiRequired.string(),
optional: joiRequired.string().optional()
}),
nested: joiAllowUnknown.object().keys({
key: joi.string()
})
})

@@ -23,3 +23,6 @@ {

"facebookId": {
"type": ["string", "null"]
"type": [
"string",
"null"
]
},

@@ -98,3 +101,4 @@ "ip": {

"name"
]
],
"additionalProperties": true
}

@@ -129,2 +133,26 @@ ]

]
},
"meta": {
"properties": {
"hash": {
"type": "string"
},
"optional": {
"type": "string"
}
},
"type": "object",
"required": [
"hash"
],
"additionalProperties": false
},
"nested": {
"properties": {
"key": {
"type": "string"
}
},
"type": "object",
"additionalProperties": true
}

@@ -134,4 +162,6 @@ },

"nickName",
"avatar"
]
"avatar",
"meta"
],
"additionalProperties": false
}
/* eslint no-use-before-define: 'off' */
const assert = require('assert')
const _ = require('lodash')

@@ -13,4 +14,6 @@

this.childrenFieldName = this._getChildrenFieldName()
this.optionsFieldName = this._getOptionsFieldName()
this.ruleArgFieldName = this._getRuleArgFieldName()
this.enumFieldName = this._getEnumFieldName()
this.allowUnknownFlagName = this._getAllowUnknownFlagName()
this.jsonSchema = this._convertSchema(this.joiDescribe)

@@ -31,2 +34,6 @@ }

_getOptionsFieldName() {
return 'options'
}
_getRuleArgFieldName() {

@@ -40,2 +47,6 @@ return 'arg'

_getAllowUnknownFlagName() {
return 'allowUnknown'
}
_convertSchema(joiDescribe) {

@@ -79,3 +90,8 @@ const schema = {}

_isRequired(fieldDefn) {
return _.get(fieldDefn, 'flags.presence') === 'required'
const presence = _.get(fieldDefn, 'flags.presence')
if (presence !== undefined) {
assert(['required', 'optional'].includes(presence), presence)
return presence === 'required'
}
return _.get(fieldDefn, `${this.optionsFieldName}.presence`) === 'required'
}

@@ -280,4 +296,5 @@

if (joiDescribe.flags && typeof joiDescribe.flags.allowUnknown !== 'undefined') {
schema.additionalProperties = joiDescribe.flags.allowUnknown
schema.additionalProperties = _.get(joiDescribe, `${this.optionsFieldName}.allowUnknown`, false)
if (joiDescribe.flags && typeof joiDescribe.flags[this.allowUnknownFlagName] !== 'undefined') {
schema.additionalProperties = joiDescribe.flags[this.allowUnknownFlagName]
}

@@ -284,0 +301,0 @@

@@ -21,2 +21,6 @@ const _ = require('lodash')

_getOptionsFieldName() {
return 'preferences'
}
_getRuleArgFieldName() {

@@ -30,2 +34,6 @@ return 'args'

_getAllowUnknownFlagName() {
return 'unknown'
}
_getFieldDescription(fieldDefn) {

@@ -32,0 +40,0 @@ return _.get(fieldDefn, 'flags.description')

2

package.json
{
"name": "joi-to-json",
"version": "1.1.1",
"version": "1.2.0",
"description": "joi to JSON Schema Converter",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc