joi-fn

1.0.1 • Public • Published

joi-fn Build Status

Return a function that runs Joi.attempt with the given validator

Install

$ npm install --save joi-fn

Usage

var joiFn = require('joi-fn')
var Joi = require('joi')
 
var validate = joiFn(Joi.string(), 'custom error')
 
// Joi will convert a number-like string to a number for us
validate('1')
// => 1
 
validate('string')
// => throws an error with "custom error" as prefix

API

joiFn(validator, [message]) -> function(value)

vaildator

Required

A Joi validator

message

Type: string|Constructor Default: ''

A string to prefix Joi's error with, or a custom Error constructor to wrap errors with.

This is passed straight to Joi.attempt().

License

MIT © Andrew Joslin

Readme

Keywords

Package Sidebar

Install

npm i joi-fn

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • andytjoslin