UNPKG

speck-entity

Version:

Domain entities with reactive validation

16 lines (13 loc) 653 B
"use strict"; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } module.exports = { Adapter: function Adapter(Joi) { return function JoiValidatorAdapter(joiChain) { return function PropTypesValidator(props, propName) { var schema = Joi.object().keys(_defineProperty({}, propName, joiChain)); var result = Joi.validate(_defineProperty({}, propName, props[propName]), schema); if (result.error) return new Error("Joi" + result.error); }; }; } };