UNPKG

express-cargo

Version:

express middleware for class-based request parsing

33 lines (32 loc) 1.02 kB
function _define_property(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; } export class CargoFieldError extends Error { constructor(property, reason){ super(`${String(property)}: ${reason}`), _define_property(this, "name", void 0); this.name = 'CargoFieldError'; } } export class CargoValidationError extends Error { constructor(errors){ super('Cargo validation failed'), _define_property(this, "name", void 0), _define_property(this, "errors", void 0); this.name = 'CargoValidationError'; this.errors = errors; } } export class CargoTransformFieldError extends CargoFieldError { constructor(property, reason){ super(property, reason), _define_property(this, "name", void 0); this.name = 'CargoTransformFieldError'; } }