title: How do I invoke my JS Function for a particular column in a csv file in the Karate Framework?
body: <p>I have a feature file that reads a csv file with multiple rows and I need to validate that if two of the columns meet certain conditions, the third column needs to be mandatory. I have tried using a js function however I am unsure as to how I should call this function for the third column. So based on the example below, if the name is Chicken, the unit kg then the cost needs to be mandatory.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>#
  noinspection CucumberTableInspection
  Feature: Serverless
  
  Scenario Outline: Per Row *
    def row =
    ""
  " {
    name: '&lt;Name&gt;',
    unit: '&lt;Unit&gt;',
    cost: '&lt;Cost&gt;',
  }
  @FunctionComparison
    ""
  " *
  def name = '&lt;Name&gt;' *
    def unit = '&lt;Unit&gt;' *
    def cost = '&lt;Cost&gt;' *
    def checkMandatory =
    ""
  "
  
  function(arg1, arg2, arg3) {
    if (arg1 in ('Chicken')) {
      if (arg2 in ('kg')) {
        if (arg3.length &lt; 0) {
        
          return false;
        }
        return true;
      }
      return true;
    }
    return true;
  }
  
  
  ""
  " *
  match row ==
    ""
  " {
    name: '#ignore',
    unit: '#regex ea|kg|ml',
    cost: 'checkMandatory(name, unit, cost) == true'
  
  }
  ""
  "
  Examples:
    |
    read('input' + '.csv') |</code></pre>
  </div>
  </div>
  </p>
  <p>The input.csv is simply a csv file with the following:</p>
  <p>Line,Name,Unit,Cost (Columns)</p>
  <p>1,Cheese,ea,34.50
  2,Cake,ea,55.54
  3,Chicken,kg,
  4,Cement,ml,4.32</p>