concisely validate javascript function inputs with joi

Usage no npm install needed!

<script type="module">
  import joiflowy from '';



Codeship Status for cdaringe/joiflowy


validate function inputs as concisely as possible, using the powerful joi


because writing defensive code can be tedious. in other words, writing code like:

if (!input.field || !input.otherField.deepField) throw new Error(${whatever})
if (!(input.otherField.deepField instanceof Function)) throw new TypeError(${whatever})

for all of the input combinations you want to protect against is often exhausting, incomplete, or too verbose. using joiflowy, you can quickly scaffold exactly what inputs will be accepted, and trash the usual boilerplate.

What's with the name?

"joiflowy" sounds close to joyfully. given that this package protects functions, a core control-flow mechanism, the combination of "joi" & "flow" only seemed appropriate.


const jf = require('joiflowy')
const sum = jf((a, b) => (a + b), jf.joi.number(), jf.joi.number())
sum(1, 2) // ==> 3
sum(1, 'bananas') // ==> throws ValidationError

need joi.validate options? no problem

const jf = require('joiflowy')
const Joi = require('joi') // jf doesn't care which joi is used. jf.joi/jf.Joi/jf.j all ==> joi
const double = jf((a) => (a * 2), Joi.number(), { convert: false })
double(2) // ==> 4
double('2') // ==> throws ValidationError