Files
loop-etl-rocketchat/lib/factory/validate.js
2026-05-13 20:03:28 +03:00

22 lines
351 B
JavaScript

const Joi = require('joi')
module.exports = function (schema, props) {
//
// Validate and remove unknown keys
//
var {error, value} = Joi.validate(props, schema, {
presence: 'required',
stripUnknown: true
})
//
// Throw validation errors
//
if (error) {
throw error
}
//
// Return the value
//
return value
}