joi-to-json
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -13,2 +13,3 @@ const joi = require('joi-12') | ||
avatar: joi.string().required().uri(), | ||
password: joi.forbidden(), | ||
email: joi.string().email(), | ||
@@ -15,0 +16,0 @@ ip: joi.string().ip({ version: ['ipv4', 'ipv6'] }), |
@@ -13,2 +13,3 @@ const joi = require('joi-13') | ||
avatar: joi.string().required().uri(), | ||
password: joi.forbidden(), | ||
email: joi.string().email(), | ||
@@ -15,0 +16,0 @@ ip: joi.string().ip({ version: ['ipv4', 'ipv6'] }), |
@@ -13,2 +13,3 @@ const joi = require('joi-14') | ||
avatar: joi.string().required().uri(), | ||
password: joi.forbidden(), | ||
email: joi.string().email(), | ||
@@ -15,0 +16,0 @@ ip: joi.string().ip({ version: ['ipv4', 'ipv6'] }), |
@@ -13,2 +13,3 @@ const joi = require('joi-15') | ||
avatar: joi.string().required().uri(), | ||
password: joi.forbidden(), | ||
email: joi.string().email(), | ||
@@ -15,0 +16,0 @@ ip: joi.string().ip({ version: ['ipv4', 'ipv6'] }), |
@@ -13,2 +13,3 @@ const joi = require('joi-16') | ||
avatar: joi.string().required().uri(), | ||
password: joi.forbidden(), | ||
email: joi.string().email(), | ||
@@ -15,0 +16,0 @@ ip: joi.string().ip({ version: ['ipv4', 'ipv6'] }), |
@@ -13,2 +13,3 @@ const joi = require('joi-17') | ||
avatar: joi.string().required().uri(), | ||
password: joi.forbidden(), | ||
email: joi.string().email(), | ||
@@ -15,0 +16,0 @@ ip: joi.string().ip({ version: ['ipv4', 'ipv6'] }), |
@@ -18,2 +18,5 @@ { | ||
}, | ||
"password": { | ||
"not": {} | ||
}, | ||
"email": { | ||
@@ -20,0 +23,0 @@ "type": "string", |
/* eslint no-use-before-define: 'off' */ | ||
const assert = require('assert') | ||
const _ = require('lodash') | ||
@@ -52,2 +51,7 @@ | ||
if (this._getPresence(joiDescribe) === 'forbidden') { | ||
schema.not = {} | ||
return schema | ||
} | ||
this._setBasicProperties(schema, joiDescribe) | ||
@@ -87,11 +91,15 @@ this._setNumberFieldProperties(schema, joiDescribe) | ||
_isRequired(fieldDefn) { | ||
_getPresence(fieldDefn) { | ||
const presence = _.get(fieldDefn, 'flags.presence') | ||
if (presence !== undefined) { | ||
assert(['required', 'optional'].includes(presence), presence) | ||
return presence === 'required' | ||
return presence | ||
} | ||
return _.get(fieldDefn, `${this.optionsFieldName}.presence`) === 'required' | ||
return _.get(fieldDefn, `${this.optionsFieldName}.presence`) | ||
} | ||
_isRequired(fieldDefn) { | ||
const presence = this._getPresence(fieldDefn) | ||
return presence === 'required' | ||
} | ||
_getDefaultValue(fieldDefn) { | ||
@@ -98,0 +106,0 @@ return _.get(fieldDefn, 'flags.default') |
{ | ||
"name": "joi-to-json", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "joi to JSON Schema Converter", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
44506
1252