1.0.1 • Published 7 years ago

joi-extension-string-valid-from-refs v1.0.1

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

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)