Skip to content

Instantly share code, notes, and snippets.

@samueljoli
Last active January 30, 2017 18:12
Show Gist options
  • Select an option

  • Save samueljoli/2c514d9beda86265d6c070ef7febeeb5 to your computer and use it in GitHub Desktop.

Select an option

Save samueljoli/2c514d9beda86265d6c070ef7febeeb5 to your computer and use it in GitHub Desktop.
// In request handler
const document = {
id : null,
name: {first: null, last: null}
};
// later in request handler
document.id = Uuid.v4();
document.name.first = computedValues.firstName;
document.name.last = computedValues.lastName;
const docSchema = Joi.object().keys({
id: Joi.string().guid().required(),
name: Joi.object().keys({
first: Joi.string().min(1).required(),
last: Joi.string().min(1).required()
}).required()
});
// in test suite
const completeMock = {
id : 'c142c479-c56e-43a8-8f3c-5db38d8061c3',
name: {
first: 'Amelia',
last : 'Pond'
}
};
const invalidMock = {
id : 'c142c479-c56e-43a8-8f3c-5db38d8061c3',
firstName: 'Martha',
lastName : 'Jones'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment