preconditions 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var errValidation = require("./singleton-validator"),
4
- _ = require("lodash");
3
+ var errValidation = require("./singleton-validator");
5
4
 
6
5
  /**
7
6
  *
@@ -27,7 +26,7 @@ class InstanceValidator {
27
26
  var current = this.out || {};
28
27
  var count = 0;
29
28
 
30
- _.forEach(variables, function (variable) {
29
+ variables.forEach((variable) => {
31
30
  // If statement needed because we need to be able to verify shouldBeUndefined.
32
31
  if (count !== variables.length - 1) {
33
32
  errValidation.shouldBeDefined(current[variable], message);
@@ -2,7 +2,7 @@
2
2
 
3
3
  var constants = require("./../constants"),
4
4
  ErrrDecorator = require("./decorator"),
5
- _ = require("lodash");
5
+ CoreUtilIs = require("core-util-is");
6
6
 
7
7
  /**
8
8
  * Validate single value with a buildable interface on top of the errr node module.
@@ -16,14 +16,14 @@ class ErrrValidator {
16
16
  /**
17
17
  * Throws an error if 'val' is not defined.
18
18
  *
19
- * @param {String} val - The value to validate.
19
+ * @param {*} val - The value to validate.
20
20
  * @param {String} [message] - The error message or the error template string to use if the ErrrValidator fails.
21
21
  * @param {Array} [template] - Template params. If provided, the error message will be generated using util.format(message, template).
22
22
  * @returns {ErrrDecorator} - An object that decorates the errr node module.
23
23
  */
24
24
  static shouldBeDefined(val, message, template) {
25
25
  function doesFail() {
26
- return _.isUndefined(val);
26
+ return CoreUtilIs.isUndefined(val);
27
27
  }
28
28
 
29
29
  message = message || constants.ShouldBeDefined;
@@ -39,7 +39,7 @@ class ErrrValidator {
39
39
  */
40
40
  static shouldBeUndefined(val, message, template) {
41
41
  function doesFail() {
42
- return !_.isUndefined(val);
42
+ return !CoreUtilIs.isUndefined(val);
43
43
  }
44
44
 
45
45
  message = message || constants.ShouldBeUndefined;
@@ -56,7 +56,7 @@ class ErrrValidator {
56
56
  */
57
57
  static shouldBeArray(val, message, template) {
58
58
  function doesFail() {
59
- return !_.isArray(val);
59
+ return !CoreUtilIs.isArray(val);
60
60
  }
61
61
 
62
62
  message = message || constants.ShouldBeArray;
@@ -72,7 +72,7 @@ class ErrrValidator {
72
72
  */
73
73
  static shouldNotBeArray(val, message, template) {
74
74
  function doesFail() {
75
- return _.isArray(val);
75
+ return CoreUtilIs.isArray(val);
76
76
  }
77
77
 
78
78
  message = message || constants.ShouldNotBeArray;
@@ -89,7 +89,7 @@ class ErrrValidator {
89
89
  */
90
90
  static shouldBeObject(val, message, template) {
91
91
  function doesFail() {
92
- return !_.isObject(val);
92
+ return !CoreUtilIs.isObject(val);
93
93
  }
94
94
 
95
95
  message = message || constants.ShouldBeObject;
@@ -105,7 +105,7 @@ class ErrrValidator {
105
105
  */
106
106
  static shouldNotBeObject(val, message, template) {
107
107
  function doesFail() {
108
- return _.isObject(val);
108
+ return CoreUtilIs.isObject(val);
109
109
  }
110
110
 
111
111
  message = message || constants.ShouldNotBeObject;
@@ -122,7 +122,7 @@ class ErrrValidator {
122
122
  */
123
123
  static shouldBeEmpty(val, message, template) {
124
124
  function doesFail() {
125
- return !_.isEmpty(val);
125
+ return !CoreUtilIs.isEmpty(val);
126
126
  }
127
127
 
128
128
  message = message || constants.ShouldBeEmpty;
@@ -138,7 +138,7 @@ class ErrrValidator {
138
138
  */
139
139
  static shouldNotBeEmpty(val, message, template) {
140
140
  function doesFail() {
141
- return _.isEmpty(val);
141
+ return CoreUtilIs.isEmpty(val);
142
142
  }
143
143
 
144
144
  message = message || constants.ShouldNotBeEmpty;
@@ -155,7 +155,7 @@ class ErrrValidator {
155
155
  */
156
156
  static shouldBeFunction(val, message, template) {
157
157
  function doesFail() {
158
- return !_.isFunction(val);
158
+ return !CoreUtilIs.isFunction(val);
159
159
  }
160
160
 
161
161
  message = message || constants.ShouldBeFunction;
@@ -171,7 +171,7 @@ class ErrrValidator {
171
171
  */
172
172
  static shouldNotBeFunction(val, message, template) {
173
173
  function doesFail() {
174
- return _.isFunction(val);
174
+ return CoreUtilIs.isFunction(val);
175
175
  }
176
176
 
177
177
  message = message || constants.ShouldNotBeFunction;
@@ -188,7 +188,7 @@ class ErrrValidator {
188
188
  */
189
189
  static shouldBeString(val, message, template) {
190
190
  function doesFail() {
191
- return !_.isString(val);
191
+ return !CoreUtilIs.isString(val);
192
192
  }
193
193
 
194
194
  message = message || constants.ShouldBeString;
@@ -204,7 +204,7 @@ class ErrrValidator {
204
204
  */
205
205
  static shouldNotBeString(val, message, template) {
206
206
  function doesFail() {
207
- return _.isString(val);
207
+ return CoreUtilIs.isString(val);
208
208
  }
209
209
 
210
210
  message = message || constants.ShouldNotBeString;
@@ -221,7 +221,7 @@ class ErrrValidator {
221
221
  */
222
222
  static shouldBeNumber(val, message, template) {
223
223
  function doesFail() {
224
- return !_.isNumber(val);
224
+ return !CoreUtilIs.isNumber(val);
225
225
  }
226
226
 
227
227
  message = message || constants.ShouldBeNumber;
@@ -237,7 +237,7 @@ class ErrrValidator {
237
237
  */
238
238
  static shouldNotBeNumber(val, message, template) {
239
239
  function doesFail() {
240
- return _.isNumber(val);
240
+ return CoreUtilIs.isNumber(val);
241
241
  }
242
242
 
243
243
  message = message || constants.ShouldNotBeNumber;
@@ -254,7 +254,7 @@ class ErrrValidator {
254
254
  */
255
255
  static shouldBeFinite(val, message, template) {
256
256
  function doesFail() {
257
- return !_.isFinite(val);
257
+ return !CoreUtilIs.isFinite(val);
258
258
  }
259
259
 
260
260
  message = message || constants.ShouldBeFinite;
@@ -270,7 +270,7 @@ class ErrrValidator {
270
270
  */
271
271
  static shouldBeInfinite(val, message, template) {
272
272
  function doesFail() {
273
- return _.isFinite(val);
273
+ return CoreUtilIs.isFinite(val);
274
274
  }
275
275
 
276
276
  message = message || constants.ShouldBeInfinite;
@@ -287,7 +287,7 @@ class ErrrValidator {
287
287
  */
288
288
  static shouldBeBoolean(val, message, template) {
289
289
  function doesFail() {
290
- return !_.isBoolean(val);
290
+ return !CoreUtilIs.isBoolean(val);
291
291
  }
292
292
 
293
293
  message = message || constants.ShouldBeBoolean;
@@ -303,7 +303,7 @@ class ErrrValidator {
303
303
  */
304
304
  static shouldNotBeBoolean(val, message, template) {
305
305
  function doesFail() {
306
- return _.isBoolean(val);
306
+ return CoreUtilIs.isBoolean(val);
307
307
  }
308
308
 
309
309
  message = message || constants.ShouldNotBeBoolean;
@@ -320,7 +320,7 @@ class ErrrValidator {
320
320
  */
321
321
  static shouldBeDate(val, message, template) {
322
322
  function doesFail() {
323
- return !_.isDate(val);
323
+ return !CoreUtilIs.isDate(val);
324
324
  }
325
325
 
326
326
  message = message || constants.ShouldBeDate;
@@ -336,7 +336,7 @@ class ErrrValidator {
336
336
  */
337
337
  static shouldNotBeDate(val, message, template) {
338
338
  function doesFail() {
339
- return _.isDate(val);
339
+ return CoreUtilIs.isDate(val);
340
340
  }
341
341
 
342
342
  message = message || constants.ShouldNotBeDate;
@@ -353,7 +353,7 @@ class ErrrValidator {
353
353
  */
354
354
  static shouldBeRegExp(val, message, template) {
355
355
  function doesFail() {
356
- return !_.isRegExp(val);
356
+ return !CoreUtilIs.isRegExp(val);
357
357
  }
358
358
 
359
359
  message = message || constants.ShouldBeRegExp;
@@ -369,7 +369,7 @@ class ErrrValidator {
369
369
  */
370
370
  static shouldNotBeRegExp(val, message, template) {
371
371
  function doesFail() {
372
- return _.isRegExp(val);
372
+ return CoreUtilIs.isRegExp(val);
373
373
  }
374
374
 
375
375
  message = message || constants.ShouldNotBeRegExp;
@@ -379,7 +379,7 @@ class ErrrValidator {
379
379
  /**
380
380
  * Throws an error if 'val' is not falsey.
381
381
  *
382
- * @param {String} val - The value to validate.
382
+ * @param {Any} val - The value to validate.
383
383
  * @param {String} [message] - The error message or the error template string to use if the ErrrValidator fails.
384
384
  * @param {Array} [template] - Template params. If provided, the error message will be generated using util.format(message, template).
385
385
  * @returns {ErrrDecorator} - An object that decorates the errr node module.
@@ -395,7 +395,7 @@ class ErrrValidator {
395
395
  /**
396
396
  * Throws an error if 'val' is falsey.
397
397
  *
398
- * @param {String} val - The value to validate.
398
+ * @param {Any} val - The value to validate.
399
399
  * @param {String} [message] - The error message or the error template string to use if the ErrrValidator fails.
400
400
  * @param {Array} [template] - Template params. If provided, the error message will be generated using util.format(message, template).
401
401
  * @returns {ErrrDecorator} - An object that decorates the errr node module.
@@ -411,7 +411,7 @@ class ErrrValidator {
411
411
  /**
412
412
  * Synonym for shouldBeFalsey.
413
413
  *
414
- * @param {String} val - The value to validate.
414
+ * @param {Any} val - The value to validate.
415
415
  * @param {String} [message] - The error message or the error template string to use if the ErrrValidator fails.
416
416
  * @param {Array} [template] - Template params. If provided, the error message will be generated using util.format(message, template).
417
417
  * @returns {ErrrDecorator} - An object that decorates the errr node module.
@@ -422,7 +422,7 @@ class ErrrValidator {
422
422
  /**
423
423
  * Synonym for shouldNotBeFalsey.
424
424
  *
425
- * @param {String} val - The value to validate.
425
+ * @param {Any} val - The value to validate.
426
426
  * @param {String} [message] - The error message or the error template string to use if the ErrrValidator fails.
427
427
  * @param {Array} [template] - Template params. If provided, the error message will be generated using util.format(message, template).
428
428
  * @returns {ErrrDecorator} - An object that decorates the errr node module.
@@ -434,7 +434,7 @@ class ErrrValidator {
434
434
  /**
435
435
  * Synonym for shouldNotBeFalsey.
436
436
  *
437
- * @param {String} val - The value to validate.
437
+ * @param {Any} val - The value to validate.
438
438
  * @param {String} [message] - The error message or the error template string to use if the ErrrValidator fails.
439
439
  * @param {Array} [template] - Template params. If provided, the error message will be generated using util.format(message, template).
440
440
  * @returns {ErrrDecorator} - An object that decorates the errr node module.
@@ -445,7 +445,7 @@ class ErrrValidator {
445
445
  /**
446
446
  * Synonym for shouldBeFalsey.
447
447
  *
448
- * @param {String} val - The value to validate.
448
+ * @param {Any} val - The value to validate.
449
449
  * @param {String} [message] - The error message or the error template string to use if the ErrrValidator fails.
450
450
  * @param {Array} [template] - Template params. If provided, the error message will be generated using util.format(message, template).
451
451
  * @returns {ErrrDecorator} - An object that decorates the errr node module.
@@ -457,7 +457,7 @@ class ErrrValidator {
457
457
  /**
458
458
  * Ensures the truth of an expression involving one or more parameters to the calling method.
459
459
  *
460
- * @param {String} expression - The value to validate.
460
+ * @param {Any} expression - The value to validate.
461
461
  * @param {String} [message] - The error message or the error template string to use if the ErrrValidator fails.
462
462
  * @param {Array} [template] - Template params. If provided, the error message will be generated using util.format(message, template).
463
463
  * @returns {ErrrDecorator} - An object that decorates the errr node module.
@@ -473,7 +473,7 @@ class ErrrValidator {
473
473
  /**
474
474
  * Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
475
475
  *
476
- * @param {String} expression - The value to validate.
476
+ * @param {Any} expression - The value to validate.
477
477
  * @param {String} [message] - The error message or the error template string to use if the ErrrValidator fails.
478
478
  * @param {Array} [template] - Template params. If provided, the error message will be generated using util.format(message, template).
479
479
  * @returns {ErrrDecorator} - An object that decorates the errr node module.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "preconditions",
3
3
  "author": "Cory Parrish",
4
4
  "main": "./lib/preconditions.js",
5
- "version": "3.0.0",
5
+ "version": "3.0.1",
6
6
  "description": "Support for Precondition error checking in Node.js.",
7
7
  "homepage": "https://github.com/corybill/preconditions",
8
8
  "bugs": {