wankdanker / node-object-mapper

Copy properties from one object to another.
MIT License
276 stars 73 forks source link

Dates not being transform proper #81

Closed gitricko closed 4 years ago

gitricko commented 4 years ago

eg:

  var src1 = { 
      'txn': [{"datamov": "07/01/2020"},{"datamov": "07/01/2020"}]
  }
  var map1 = {
    "txn[].datamov": {
      key: "txn[].dat",
      transform: val => moment(val, 'DD/MM/YYYY').format('YYYY-MM-DD')
    }
  };
  var expect = { 
      'txn': [{"datamov": "2020-07-01"},{"datamov": "2020-07-01"}]
  }
  var result = om(src1, map1);

but what i got was: { txn: [ { dat: 'Invalid date' }, { dat: 'Invalid date' } ] }

Could not figure out what was wrong

gitricko commented 4 years ago

Closing this but will watch #77