1.0.1 • Published 8 years ago

joi-fn v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

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

1.0.1

8 years ago

1.0.0

8 years ago