parameter icon indicating copy to clipboard operation
parameter copied to clipboard

convertType didn't work with array

Open fisherwei opened this issue 5 years ago • 1 comments

rule: { category: { type: 'array', itemType: 'int', required: false, } }

data: { category: [ '403', '407', '303', '307' ] }

fisherwei avatar Apr 27 '20 09:04 fisherwei

目前不支持array converthttps://github.com/node-modules/parameter/blob/6e252719803a583a778541f46d7d581f248258f3/index.js#L275 只能修改代码解决

  // convertType support array
  if(Array.isArray(value)){
    switch (convertType) {
      case 'int':
      case 'number':
        obj[key] = value.map((val) => Number(val));
      default:
    }
    return
  }

ckvv avatar Aug 14 '20 08:08 ckvv