Skip to content

Latest commit

 

History

History
85 lines (76 loc) · 3.18 KB

user-supplied-input.md

File metadata and controls

85 lines (76 loc) · 3.18 KB

User-Supplied Input

User-supplied input is data that the end-user will provide. It's the data that the function operates on.

It is passed into your function as one or more parameters.

For example:

function queryDatastore(
    logger: Logger,
    db: DbConn,
    sql: string
): unknown {
    logger.logInfo("querying the datastore!")
    return db.query(sql);
}

const query = (sql: string): unknown => queryDatastore(myLogger, myDB);

In this example:

  • both logger and db are mandatory dependencies. They're functions that your code calls.
  • sql is user-supplied input. It's data passed in by the end-user.

It's perfectly normal for mandatory dependencies to be hidden in a wrapping function of some kind, just like what happens in query(). User-supplied input, on the other hand, is almost never hidden behind a wrapping function. Note how query() passes the sql parameter through to the general function queryDatastore().