Skip to content

Instantly share code, notes, and snippets.

@Xordal
Created September 6, 2018 17:23
Show Gist options
  • Save Xordal/78812561130530af8b6d7888ab3dd60e to your computer and use it in GitHub Desktop.
Save Xordal/78812561130530af8b6d7888ab3dd60e to your computer and use it in GitHub Desktop.
joi arrays validation
{
"cart_id": 56,
"drugs": [
{
"id": 8,
"count": 2
},
{
"id": 456,
"count": 0
}
]
}
const joi = require("joi");
module.exports = {
batchUpdate: {
body: {
cart_id: joi
.number()
.integer()
.min(1),
drugs: joi.array().items(
joi.object().keys({
id: joi
.number()
.integer()
.min(1),
count: joi
.number()
.integer()
.min(0)
})
)
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment