joi-extension-string-valid-from-refs

1.0.1 • Public • Published

joi-extension-string-validFromRefs

An extension to Joi to enable checking that a string is composed from a number of refs.

In the below example we are confirming that fullName is composed from firstName and lastName

var Joi = require('joi').extend(require('joi-extension-string-valid-from-refs'));
 
var schema = Joi.object({
  firstName: Joi.string().required(),
  lastName: Joi.string().required(),
  fullName: Joi.string().required().validFromRefs(['lastName', 'firstName'], '')
});
 
var input = {
  fistName: 'John',
  lastName: 'Smith',
  fullName: 'Smith, John'
};
 
Joi.assert(input, schema)

Package Sidebar

Install

npm i joi-extension-string-valid-from-refs

Weekly Downloads

2

Version

1.0.1

License

MIT

Last publish

Collaborators

  • b2mdevelopment