From 51c01cda252d0f75617c3d8bbfc8bdb4cb6e7012 Mon Sep 17 00:00:00 2001 From: issac Date: Wed, 3 Feb 2021 14:26:58 +0800 Subject: [PATCH] support convert object --- index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index e1db09a..8f10747 100644 --- a/index.js +++ b/index.js @@ -271,13 +271,15 @@ function convert(rule, obj, key, defaultConvert) { if (!convertType) return; const value = obj[key]; - // convert type only work for primitive data - if (typeof value === 'object') return; - + + // if set convertType function it should be support convert object // convertType support function if (typeof convertType === 'function') { obj[key] = convertType(value, obj); return; + }else{ + // default convert type only work for primitive data + if (typeof value === 'object') return; } switch (convertType) {