Skip to content

Instantly share code, notes, and snippets.

@Clement-TS
Last active July 15, 2016 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Clement-TS/060e055919c828dfd0bab2dbd0fa59c0 to your computer and use it in GitHub Desktop.
Save Clement-TS/060e055919c828dfd0bab2dbd0fa59c0 to your computer and use it in GitHub Desktop.
joijs test
/**
* @author Clément Désiles <clement.desiles@telecomsante.com>
* @date 2016-07-12
* @description Record model
*/
'use strict'
const joi = require('joi')
module.exports = joi.object().keys({
// mongo ObjectId
_id: joi.string().lowercase().length(24).hex(),
// title is required
title: joi.string().required(),
// at least one author or one editor is required
author: joi.string(),
editor: joi.string(),
// optional parameters
category: joi.string(),
tag: joi.string(),
since: joi.string(),
date: joi.string(),
// optional array, but when specified, every field is required
custom: joi.array().items(joi.object().keys({
label: joi.string().required(),
value: joi.string().required(),
visible: joi.string().required()
}))
}).or('author', 'editor')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment