Skip to content

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

License

Notifications You must be signed in to change notification settings

B2MSolutions/joi-extension-string-validFromRefs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published