Last active
July 15, 2016 12:31
-
-
Save Clement-TS/060e055919c828dfd0bab2dbd0fa59c0 to your computer and use it in GitHub Desktop.
joijs test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author Clément Désiles <[email protected]> | |
* @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