Uploaded image for project: 'Fluid Infusion'
  1. Fluid Infusion
  2. FLUID-5300

fluid.transforms.valueMapper requires outputValue (or outputPath) being specified for the output object

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      When a literal value needs to be mapped to an object that has multiple paths and values, for example:

      var inputModel = {
          hazard: "flashing"
      };
      
      var expectedTransformedObject = {
          hasHazard: true,
          audio: true
      };
      

      The transformation rule that performs this transformation successfully looks like:

      {
          type: "fluid.transforms.valueMapper",
          inputPath: "hazard",
          options: {
              "flashing": {
                  "outputValue": {
                      transform: [{
                          type: "fluid.transforms.literalValue",
                          value: true,
                          outputPath: "hasHazard"
                      }, {
                          type: "fluid.transforms.literalValue",
                          value: true,
                          outputPath: "sound"
                      }]
                  }
              }
          }
      };
      

      Note that in this rule:
      1. "outputValue" needs to be specified as a key in the map options;
      2. Nested transformation rules needs to be defined for each output key value pair rather than a direct compound values.

      It would be nice to simplify the rule to be:

      {
          type: "fluid.transforms.valueMapper",
          inputPath: "hazard",
          options: {
              "flashing": {
                  "hasHazard": true,
                  "sound": true
              }
          }
      }
      

      In today's conversation at irc channel, Antranig expressed concerns that the implementation of the valueMapper is not consistent with that of our other transforms:

      https://botbot.me/freenode/fluid-work/2014-04-02/?tz=America/Havana

      at 11:19AM onwards.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kaspermarkus Kasper Galschiot Markus
                Reporter:
                cli@ocad.ca Cindy Qi Li
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: