@elliemae/ds-props-helpers
Advanced tools
Comparing version 1.54.0-next.2 to 1.54.0-next.3
@@ -14,2 +14,12 @@ 'use strict'; | ||
schema.properties.forEach(function (property) { | ||
var propertyName = property.name; | ||
var currentProp = props[propertyName]; | ||
var currentPropTypeOf = _typeof__default['default'](currentProp); // eslint-disable-next-line max-len | ||
var currentFormat = property.format; // this is csv representing types e.g.: "string"/"string,number"/"[object],string" | ||
var isValidReactElement = false; // this depends on react desc definition | ||
if (property.required && !Object.prototype.hasOwnProperty.call(props, property.name)) { | ||
@@ -19,6 +29,10 @@ validation_errorTemplates.throwRequiredError(schema.name, property.name); | ||
if (typeof props[property.name] !== 'undefined' && props[property.name] !== null) { | ||
if (!property.format.includes(_typeof__default['default'](props[property.name])) && !property.format.includes(props[property.name])) { | ||
validation_errorTemplates.throwTypeError(schema.name, property.name, props[property.name], property.format); | ||
if (currentPropTypeOf !== 'undefined' && currentProp !== null) { | ||
if (currentPropTypeOf === 'object' && Object.prototype.hasOwnProperty.call(currentProp, '$$typeof') && (currentFormat.includes('node') || currentFormat.includes('element'))) { | ||
isValidReactElement = true; | ||
} | ||
if (!currentFormat.includes(currentPropTypeOf) && !currentFormat.includes(currentProp) && !isValidReactElement) { | ||
validation_errorTemplates.throwTypeError(schema.name, propertyName, currentProp, currentFormat); | ||
} | ||
} | ||
@@ -25,0 +39,0 @@ }); |
@@ -6,2 +6,12 @@ import _typeof from '@babel/runtime/helpers/esm/typeof'; | ||
schema.properties.forEach(function (property) { | ||
var propertyName = property.name; | ||
var currentProp = props[propertyName]; | ||
var currentPropTypeOf = _typeof(currentProp); // eslint-disable-next-line max-len | ||
var currentFormat = property.format; // this is csv representing types e.g.: "string"/"string,number"/"[object],string" | ||
var isValidReactElement = false; // this depends on react desc definition | ||
if (property.required && !Object.prototype.hasOwnProperty.call(props, property.name)) { | ||
@@ -11,6 +21,10 @@ throwRequiredError(schema.name, property.name); | ||
if (typeof props[property.name] !== 'undefined' && props[property.name] !== null) { | ||
if (!property.format.includes(_typeof(props[property.name])) && !property.format.includes(props[property.name])) { | ||
throwTypeError(schema.name, property.name, props[property.name], property.format); | ||
if (currentPropTypeOf !== 'undefined' && currentProp !== null) { | ||
if (currentPropTypeOf === 'object' && Object.prototype.hasOwnProperty.call(currentProp, '$$typeof') && (currentFormat.includes('node') || currentFormat.includes('element'))) { | ||
isValidReactElement = true; | ||
} | ||
if (!currentFormat.includes(currentPropTypeOf) && !currentFormat.includes(currentProp) && !isValidReactElement) { | ||
throwTypeError(schema.name, propertyName, currentProp, currentFormat); | ||
} | ||
} | ||
@@ -17,0 +31,0 @@ }); |
{ | ||
"name": "@elliemae/ds-props-helpers", | ||
"version": "1.54.0-next.2", | ||
"version": "1.54.0-next.3", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Ellie Mae - Dim Sum - Validation Helpers", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
28026
192