joi-fp
Provides a few wrappers around Joi's validate()
, attempt()
and assert()
functions with their arguments
re-ordered for easier currying / partial application
Installation:
npm i joi-fp
What problem does this solve?
When using functions like joi.validate()
, you will almost always have values for schema
and/or options
before you have the value
being validated. This little library re-orders the arguments of joi.validate()
, joi.attempt()
and joi.assert()
allowing you to pass the data you have initially, well, initially :) This library also has a few versions of these functions with fixed arities to make currying and partial application easier.
Quick Example
const _ = const joi = // example with curryingconst validateInput = _ name: joiallowUnknown: true; // { error: null, value: { name: 'Max', color: 'blue' } } // example with partial applicationconst validateInputAgain = _;
Functions
// fixed arity for easy currying / partial application