joi-extension-string-valid-from-refs
v1.0.1
Published
Adds within validation to enable you to validate string value from composing different joi references
Downloads
13
Maintainers
Readme
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)