{"record":{"id":"f8b0460f4487a51e","repo":"pentaho/pentaho-kettle","slug":"the-function-call-isdate-requires-1-argument","errorCode":null,"errorMessage":"The function call isDate requires 1 argument.","messagePattern":"The function call isDate requires 1 argument\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":1474,"sourceCode":"  }\n\n  public static Object isDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n\n    if ( ArgList.length == 1 ) {\n      try {\n        if ( isNull( ArgList[0] ) ) {\n          return null;\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return undefinedValue;\n        }\n        /* java.util.Date d = (java.util.Date) */\n        return Boolean.TRUE;\n      } catch ( Exception e ) {\n        return Boolean.FALSE;\n      }\n    } else {\n      throw new RuntimeException( \"The function call isDate requires 1 argument.\" );\n    }\n  }\n\n  public static Object decode( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n    try {\n      if ( ArgList.length >= 2 ) {\n        if ( isNull( ArgList, new int[] { 0, 1 } ) ) {\n          return null;\n        } else if ( isUndefined( ArgList, new int[] { 0, 1 } ) ) {\n          return undefinedValue;\n        }\n        Object objToCompare = ArgList[0];\n        for ( int i = 1; i < ArgList.length - 1; i = i + 2 ) {\n          if ( ArgList[i].equals( objToCompare ) ) {\n            return ArgList[i + 1];\n          }\n        }","sourceCodeStart":1456,"sourceCodeEnd":1492,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L1456-L1492","documentation":"isDate validates that its single argument can be evaluated as a date. If the function is called with anything other than exactly one argument, this RuntimeException is thrown rather than returning Boolean.FALSE.","triggerScenarios":"Calling isDate() with zero arguments, or isDate(a, b) with more than one, inside a JavaScript step.","commonSituations":"Same arity mistakes as isNum: stray commas, batch attempts, refactoring leftovers.","solutions":["Call isDate with exactly one argument.","Ensure the value passed is a string/date that JavaScript's Date parsing can handle (valid dates return TRUE; unparseable values return FALSE, only wrong arity throws).","Split multi-value checks into separate calls."],"exampleFix":"// before\nvar ok = isDate(d1, d2); // throws\n// after\nvar ok = isDate(d1) && isDate(d2);","handlingStrategy":"validation","validationCode":"function safeIsDate(v) {\n  return (arguments.length === 1) ? isDate(v) : false;\n}","typeGuard":"function isDateLike(v) {\n  return v instanceof Date || (typeof v === 'string' && !isNaN(Date.parse(v)));\n}","tryCatchPattern":"try {\n  var ok = isDate(v);\n} catch (e) {\n  var ok = false; // wrong arity, not an invalid date\n}","preventionTips":["Call isDate with exactly one argument.","Remember: unparseable dates return FALSE; only wrong arity throws.","Guard multiple values with separate calls."],"tags":["java","pdi","scripting","argument-count"],"backgroundTag":"missing-required-argument","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}