Transform Record Keys

Hey, I'm just wondering if there is a way I can extract the keys from the object key. I basically want to get the value from within the () *(This data comes from a spreadsheet with 100+ columns. So excuse the terrible format). *

const dataFields = Schema.Record({ 
  key: Schema.String.pipe(Schema.pattern(/(.*)\s*\((.*)\)/)), 
  value: Schema.String 
})

console.log(Schema.decodeUnknown(dataFields)({
  "Colour (colour)": "night",
  "Weight (weight)": "2 gm"
})) // goal outcome { colour: "night", weight: "2 gm"}
Was this page helpful?