From 78f514a003e81ad33f4fda9e0b1c266cd7e12215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Thu, 2 Jan 2014 10:31:47 +0100 Subject: [PATCH] Add ValidationError to loopback exports. Simplify the construction of validation errors in user-land code: var error = new loopback.ValidationError(invalidModel); --- index.js | 2 ++ test/loopback.test.js | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/index.js b/index.js index 737666bd..d9099a70 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ */ var loopback = module.exports = require('./lib/loopback'); +var datasourceJuggler = require('loopback-datasource-juggler'); /** * Connectors @@ -17,3 +18,4 @@ loopback.Mail = require('./lib/connectors/mail'); */ loopback.GeoPoint = require('loopback-datasource-juggler/lib/geo').GeoPoint; +loopback.ValidationError = datasourceJuggler.ValidationError; diff --git a/test/loopback.test.js b/test/loopback.test.js index ebbbee21..d3650953 100644 --- a/test/loopback.test.js +++ b/test/loopback.test.js @@ -1,4 +1,11 @@ describe('loopback', function() { + describe('exports', function() { + it('ValidationError', function() { + expect(loopback.ValidationError).to.be.a('function') + .and.have.property('name', 'ValidationError'); + }); + }); + describe('loopback.createDataSource(options)', function(){ it('Create a data source with a connector.', function() { var dataSource = loopback.createDataSource({