From 21db30e84fd2891aa510b161f50b07e7bf9f75b6 Mon Sep 17 00:00:00 2001 From: ZiBY Date: Sat, 24 Feb 2018 19:52:46 +0200 Subject: [PATCH] fix check type by instance export default { props: { day: PropTypes.shape({ date: PropTypes.instanceOf(moment().constructor) }) } } --- src/validator.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/validator.js b/src/validator.js index 86ba5d6..1e08973 100644 --- a/src/validator.js +++ b/src/validator.js @@ -206,9 +206,11 @@ function isType(type, item, nullAllowed = false) { if (Array === type && Array.isArray(item)) return true - return some(TYPES, + if (some(TYPES, (TYPE, key) => (TYPE === type && typeof item === key) // eslint-disable-line valid-typeof - ) + )) return true + + return item instanceof type } function ensureOne(items) {