@nr1e/commons 0.0.2-alpha.2 → 0.0.2-alpha.3

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.
@@ -0,0 +1,47 @@
1
+ import { HttpStatusCode } from '../http';
2
+ interface IError {
3
+ stack?: string;
4
+ message?: string;
5
+ name?: string;
6
+ statusCode?: HttpStatusCode | number;
7
+ }
8
+ /**
9
+ * Checks if the given variable is a NotFoundError.
10
+ *
11
+ * @param e the variable to check
12
+ */
13
+ export declare function isNotFoundError(e?: IError | null): e is NotFoundError;
14
+ /**
15
+ * Thrown when a resource cannot be found.
16
+ */
17
+ export declare class NotFoundError extends Error {
18
+ readonly statusCode = HttpStatusCode.NOT_FOUND;
19
+ constructor(message?: string);
20
+ }
21
+ /**
22
+ * Checks if the given variable is a ForbiddenError.
23
+ *
24
+ * @param e the variable to check
25
+ */
26
+ export declare function isForbiddenError(e?: IError | null): e is ForbiddenError;
27
+ /**
28
+ * Thrown when a requested operations is not allowed.
29
+ */
30
+ export declare class ForbiddenError extends Error {
31
+ readonly statusCode = HttpStatusCode.FORBIDDEN;
32
+ constructor(message?: string);
33
+ }
34
+ /**
35
+ * Checks if the given variable is a ValidationError.
36
+ *
37
+ * @param e the variable to check
38
+ */
39
+ export declare function isValidationError(e?: IError | null): e is ValidationError;
40
+ /**
41
+ * Thrown when a validation error occurs.
42
+ */
43
+ export declare class ValidationError extends Error {
44
+ readonly statusCode = HttpStatusCode.BAD_REQUEST;
45
+ constructor(message?: string);
46
+ }
47
+ export {};
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationError = exports.isValidationError = exports.ForbiddenError = exports.isForbiddenError = exports.NotFoundError = exports.isNotFoundError = void 0;
4
+ const http_1 = require("../http");
5
+ /**
6
+ * Checks if the given variable is a NotFoundError.
7
+ *
8
+ * @param e the variable to check
9
+ */
10
+ function isNotFoundError(e) {
11
+ return !!(e &&
12
+ e.stack &&
13
+ e.message &&
14
+ e.statusCode &&
15
+ e.name &&
16
+ e.name === 'NotFoundError');
17
+ }
18
+ exports.isNotFoundError = isNotFoundError;
19
+ /**
20
+ * Thrown when a resource cannot be found.
21
+ */
22
+ class NotFoundError extends Error {
23
+ constructor(message) {
24
+ super(message !== null && message !== void 0 ? message : 'Not found');
25
+ this.statusCode = http_1.HttpStatusCode.NOT_FOUND;
26
+ this.name = 'NotFoundError';
27
+ }
28
+ }
29
+ exports.NotFoundError = NotFoundError;
30
+ /**
31
+ * Checks if the given variable is a ForbiddenError.
32
+ *
33
+ * @param e the variable to check
34
+ */
35
+ function isForbiddenError(e) {
36
+ return !!(e &&
37
+ e.stack &&
38
+ e.message &&
39
+ e.statusCode &&
40
+ e.name &&
41
+ e.name === 'ForbiddenError');
42
+ }
43
+ exports.isForbiddenError = isForbiddenError;
44
+ /**
45
+ * Thrown when a requested operations is not allowed.
46
+ */
47
+ class ForbiddenError extends Error {
48
+ constructor(message) {
49
+ super(message !== null && message !== void 0 ? message : 'Forbidden');
50
+ this.statusCode = http_1.HttpStatusCode.FORBIDDEN;
51
+ this.name = 'ForbiddenError';
52
+ }
53
+ }
54
+ exports.ForbiddenError = ForbiddenError;
55
+ /**
56
+ * Checks if the given variable is a ValidationError.
57
+ *
58
+ * @param e the variable to check
59
+ */
60
+ function isValidationError(e) {
61
+ return !!(e &&
62
+ e.stack &&
63
+ e.message &&
64
+ e.statusCode &&
65
+ e.name === 'ValidationError');
66
+ }
67
+ exports.isValidationError = isValidationError;
68
+ /**
69
+ * Thrown when a validation error occurs.
70
+ */
71
+ class ValidationError extends Error {
72
+ constructor(message) {
73
+ super(message !== null && message !== void 0 ? message : 'Validation error');
74
+ this.statusCode = http_1.HttpStatusCode.BAD_REQUEST;
75
+ this.name = 'ValidationError';
76
+ }
77
+ }
78
+ exports.ValidationError = ValidationError;
79
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sour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AI,KAAK,iBAAiB,CAC7B,CAAC;AACJ,CAAC;AARD,8CAQC;AAED;;GAEG;AACH,MAAa,eAAgB,SAAQ,KAAK;IAGxC,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,kBAAkB,CAAC,CAAC;QAH9B,eAAU,GAAG,qBAAc,CAAC,WAAW,CAAC;QAI/C,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAPD,0CAOC"}
@@ -0,0 +1 @@
1
+ export * from './errors';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./errors"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
@@ -0,0 +1,9 @@
1
+ export declare enum HttpMethod {
2
+ GET = "GET",
3
+ POST = "POST",
4
+ PUT = "PUT",
5
+ PATCH = "PATCH",
6
+ DELETE = "DELETE",
7
+ HEAD = "HEAD",
8
+ OPTIONS = "OPTIONS"
9
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpMethod = void 0;
4
+ var HttpMethod;
5
+ (function (HttpMethod) {
6
+ HttpMethod["GET"] = "GET";
7
+ HttpMethod["POST"] = "POST";
8
+ HttpMethod["PUT"] = "PUT";
9
+ HttpMethod["PATCH"] = "PATCH";
10
+ HttpMethod["DELETE"] = "DELETE";
11
+ HttpMethod["HEAD"] = "HEAD";
12
+ HttpMethod["OPTIONS"] = "OPTIONS";
13
+ })(HttpMethod || (exports.HttpMethod = HttpMethod = {}));
14
+ //# sourceMappingURL=http-method.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-method.js","sourceRoot":"","sources":["http-method.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAQX;AARD,WAAY,UAAU;IACpB,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,6BAAe,CAAA;IACf,+BAAiB,CAAA;IACjB,2BAAa,CAAA;IACb,iCAAmB,CAAA;AACrB,CAAC,EARW,UAAU,0BAAV,UAAU,QAQrB"}
@@ -0,0 +1,42 @@
1
+ export declare enum HttpStatusCode {
2
+ CONTINUE = 100,
3
+ SWITCHING_PROTOCOLS = 101,
4
+ OK = 200,
5
+ CREATED = 201,
6
+ ACCEPTED = 202,
7
+ NON_AUTHORITATIVE_INFORMATION = 203,
8
+ NO_CONTENT = 204,
9
+ RESET_CONTENT = 205,
10
+ PARTIAL_CONTENT = 206,
11
+ MULTIPLE_CHOICES = 300,
12
+ PERMANENT_REDIRECT = 301,
13
+ FOUND = 302,
14
+ SEE_OTHER = 303,
15
+ NOT_MODIFIED = 304,
16
+ USE_PROXY = 305,
17
+ TEMPORARY_REDIRECT = 307,
18
+ BAD_REQUEST = 400,
19
+ UNAUTHORIZED = 401,
20
+ PAYMENT_REQUIRED = 402,
21
+ FORBIDDEN = 403,
22
+ NOT_FOUND = 404,
23
+ METHOD_NOT_ALLOWED = 405,
24
+ NOT_ACCEPTABLE = 406,
25
+ PROXY_AUTHENTICATION_REQUIRED = 407,
26
+ REQUEST_TIMEOUT = 408,
27
+ CONFLICT = 409,
28
+ GONE = 410,
29
+ LENGTH_REQUIRED = 411,
30
+ PRECONDITION_FAILED = 412,
31
+ REQUEST_ENTITY_TOO_LARGE = 413,
32
+ REQUEST_URI_TOO_LONG = 414,
33
+ UNSUPPORTED_MEDIA_TYPE = 415,
34
+ RANGE_NOT_SATISFIABLE = 416,
35
+ EXPECTATION_FAILED = 417,
36
+ INTERNAL_ERROR = 500,
37
+ NOT_IMPLEMENTED = 501,
38
+ BAD_GATEWAY = 502,
39
+ SERVICE_UNAVAILABLE = 503,
40
+ GATEWAY_TIMEOUT = 504,
41
+ HTTP_VERSION_NOT_SUPPORTED = 505
42
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpStatusCode = void 0;
4
+ var HttpStatusCode;
5
+ (function (HttpStatusCode) {
6
+ HttpStatusCode[HttpStatusCode["CONTINUE"] = 100] = "CONTINUE";
7
+ HttpStatusCode[HttpStatusCode["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
8
+ HttpStatusCode[HttpStatusCode["OK"] = 200] = "OK";
9
+ HttpStatusCode[HttpStatusCode["CREATED"] = 201] = "CREATED";
10
+ HttpStatusCode[HttpStatusCode["ACCEPTED"] = 202] = "ACCEPTED";
11
+ HttpStatusCode[HttpStatusCode["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
12
+ HttpStatusCode[HttpStatusCode["NO_CONTENT"] = 204] = "NO_CONTENT";
13
+ HttpStatusCode[HttpStatusCode["RESET_CONTENT"] = 205] = "RESET_CONTENT";
14
+ HttpStatusCode[HttpStatusCode["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
15
+ HttpStatusCode[HttpStatusCode["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
16
+ HttpStatusCode[HttpStatusCode["PERMANENT_REDIRECT"] = 301] = "PERMANENT_REDIRECT";
17
+ HttpStatusCode[HttpStatusCode["FOUND"] = 302] = "FOUND";
18
+ HttpStatusCode[HttpStatusCode["SEE_OTHER"] = 303] = "SEE_OTHER";
19
+ HttpStatusCode[HttpStatusCode["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
20
+ HttpStatusCode[HttpStatusCode["USE_PROXY"] = 305] = "USE_PROXY";
21
+ HttpStatusCode[HttpStatusCode["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
22
+ HttpStatusCode[HttpStatusCode["BAD_REQUEST"] = 400] = "BAD_REQUEST";
23
+ HttpStatusCode[HttpStatusCode["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
24
+ HttpStatusCode[HttpStatusCode["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
25
+ HttpStatusCode[HttpStatusCode["FORBIDDEN"] = 403] = "FORBIDDEN";
26
+ HttpStatusCode[HttpStatusCode["NOT_FOUND"] = 404] = "NOT_FOUND";
27
+ HttpStatusCode[HttpStatusCode["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
28
+ HttpStatusCode[HttpStatusCode["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
29
+ HttpStatusCode[HttpStatusCode["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
30
+ HttpStatusCode[HttpStatusCode["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
31
+ HttpStatusCode[HttpStatusCode["CONFLICT"] = 409] = "CONFLICT";
32
+ HttpStatusCode[HttpStatusCode["GONE"] = 410] = "GONE";
33
+ HttpStatusCode[HttpStatusCode["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
34
+ HttpStatusCode[HttpStatusCode["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
35
+ HttpStatusCode[HttpStatusCode["REQUEST_ENTITY_TOO_LARGE"] = 413] = "REQUEST_ENTITY_TOO_LARGE";
36
+ HttpStatusCode[HttpStatusCode["REQUEST_URI_TOO_LONG"] = 414] = "REQUEST_URI_TOO_LONG";
37
+ HttpStatusCode[HttpStatusCode["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
38
+ HttpStatusCode[HttpStatusCode["RANGE_NOT_SATISFIABLE"] = 416] = "RANGE_NOT_SATISFIABLE";
39
+ HttpStatusCode[HttpStatusCode["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
40
+ HttpStatusCode[HttpStatusCode["INTERNAL_ERROR"] = 500] = "INTERNAL_ERROR";
41
+ HttpStatusCode[HttpStatusCode["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
42
+ HttpStatusCode[HttpStatusCode["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
43
+ HttpStatusCode[HttpStatusCode["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
44
+ HttpStatusCode[HttpStatusCode["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
45
+ HttpStatusCode[HttpStatusCode["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
46
+ })(HttpStatusCode || (exports.HttpStatusCode = HttpStatusCode = {}));
47
+ //# sourceMappingURL=http-status-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-status-code.js","sourceRoot":"","sources":["http-status-code.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAyCX;AAzCD,WAAY,cAAc;IACxB,6DAAc,CAAA;IACd,mFAAyB,CAAA;IACzB,iDAAQ,CAAA;IACR,2DAAa,CAAA;IACb,6DAAc,CAAA;IACd,uGAAmC,CAAA;IACnC,iEAAgB,CAAA;IAChB,uEAAmB,CAAA;IACnB,2EAAqB,CAAA;IACrB,6EAAsB,CAAA;IACtB,iFAAwB,CAAA;IACxB,uDAAW,CAAA;IACX,+DAAe,CAAA;IACf,qEAAkB,CAAA;IAClB,+DAAe,CAAA;IACf,iFAAwB,CAAA;IACxB,mEAAiB,CAAA;IACjB,qEAAkB,CAAA;IAClB,6EAAsB,CAAA;IACtB,+DAAe,CAAA;IACf,+DAAe,CAAA;IACf,iFAAwB,CAAA;IACxB,yEAAoB,CAAA;IACpB,uGAAmC,CAAA;IACnC,2EAAqB,CAAA;IACrB,6DAAc,CAAA;IACd,qDAAU,CAAA;IACV,2EAAqB,CAAA;IACrB,mFAAyB,CAAA;IACzB,6FAA8B,CAAA;IAC9B,qFAA0B,CAAA;IAC1B,yFAA4B,CAAA;IAC5B,uFAA2B,CAAA;IAC3B,iFAAwB,CAAA;IACxB,yEAAoB,CAAA;IACpB,2EAAqB,CAAA;IACrB,mEAAiB,CAAA;IACjB,mFAAyB,CAAA;IACzB,2EAAqB,CAAA;IACrB,iGAAgC,CAAA;AAClC,CAAC,EAzCW,cAAc,8BAAd,cAAc,QAyCzB"}
@@ -0,0 +1 @@
1
+ export * from './http-status-code';
package/http/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./http-status-code"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
package/index.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export * as validator from './validator';
2
+ export * as errors from './errors';
3
+ export * as http from './http';
package/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validator = void 0;
3
+ exports.http = exports.errors = exports.validator = void 0;
4
4
  exports.validator = require("./validator");
5
+ exports.errors = require("./errors");
6
+ exports.http = require("./http");
5
7
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,2CAAyC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AACzC,qCAAmC;AACnC,iCAA+B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nr1e/commons",
3
3
  "description": "Provides common patterns for validation",
4
- "version": "0.0.2-alpha.2",
4
+ "version": "0.0.2-alpha.3",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "author": "NR1E, Inc.",
@@ -30,6 +30,8 @@
30
30
  "exports": {
31
31
  ".": "./index.js",
32
32
  "./package.json": "./package.json",
33
+ "./http": "./http/index.js",
34
+ "./errors": "./errors/index.js",
33
35
  "./validator": "./validator/index.js"
34
36
  },
35
37
  "scripts": {
@@ -1,2 +1 @@
1
1
  export * from './validators';
2
- export * from './validation-error';
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./validators"), exports);
18
- __exportStar(require("./validation-error"), exports);
19
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,qDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateString = exports.betweenValues = exports.maxValue = exports.minValue = exports.isNumber = exports.minLength = exports.maxLength = exports.isEmail = exports.matches = exports.notBlank = exports.notEmpty = exports.notNull = void 0;
4
- const validation_error_1 = require("./validation-error");
4
+ const errors_1 = require("../errors");
5
5
  /**
6
6
  * Throws a ValidationError if the value is null or undefined.
7
7
  * This function also asserts the value to be NonNullable if the check passes.
@@ -11,7 +11,7 @@ const validation_error_1 = require("./validation-error");
11
11
  */
12
12
  function notNull(name, o) {
13
13
  if (o === undefined || o === null) {
14
- throw new validation_error_1.ValidationError(`${name} may not be null or undefined`);
14
+ throw new errors_1.ValidationError(`${name} may not be null or undefined`);
15
15
  }
16
16
  }
17
17
  exports.notNull = notNull;
@@ -24,7 +24,7 @@ exports.notNull = notNull;
24
24
  */
25
25
  function notEmpty(name, o) {
26
26
  if (o === undefined || o === null || o.toString().length === 0) {
27
- throw new validation_error_1.ValidationError(`${name} may not be empty`);
27
+ throw new errors_1.ValidationError(`${name} may not be empty`);
28
28
  }
29
29
  }
30
30
  exports.notEmpty = notEmpty;
@@ -37,7 +37,7 @@ exports.notEmpty = notEmpty;
37
37
  */
38
38
  function notBlank(name, o) {
39
39
  if (o === undefined || o === null || o.toString().trim().length === 0) {
40
- throw new validation_error_1.ValidationError(`${name} may not be blank`);
40
+ throw new errors_1.ValidationError(`${name} may not be blank`);
41
41
  }
42
42
  }
43
43
  exports.notBlank = notBlank;
@@ -51,7 +51,7 @@ exports.notBlank = notBlank;
51
51
  */
52
52
  function matches(name, regex, o) {
53
53
  if (o !== undefined && o !== null && !o.match(regex)) {
54
- throw new validation_error_1.ValidationError(`${name} must match ${regex}`);
54
+ throw new errors_1.ValidationError(`${name} must match ${regex}`);
55
55
  }
56
56
  }
57
57
  exports.matches = matches;
@@ -65,7 +65,7 @@ exports.matches = matches;
65
65
  function isEmail(name, o) {
66
66
  const expression = /^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;
67
67
  if (o !== undefined && o !== null && !expression.test(o)) {
68
- throw new validation_error_1.ValidationError(`${name} is not a valid email address`);
68
+ throw new errors_1.ValidationError(`${name} is not a valid email address`);
69
69
  }
70
70
  }
71
71
  exports.isEmail = isEmail;
@@ -79,7 +79,7 @@ exports.isEmail = isEmail;
79
79
  */
80
80
  function maxLength(name, length, o) {
81
81
  if (o !== undefined && o !== null && o.length > length) {
82
- throw new validation_error_1.ValidationError(`length of ${name} may not exceed ${length}`);
82
+ throw new errors_1.ValidationError(`length of ${name} may not exceed ${length}`);
83
83
  }
84
84
  }
85
85
  exports.maxLength = maxLength;
@@ -93,7 +93,7 @@ exports.maxLength = maxLength;
93
93
  */
94
94
  function minLength(name, length, o) {
95
95
  if (o !== undefined && o !== null && o.length < length) {
96
- throw new validation_error_1.ValidationError(`length of ${name} may not be less than ${length}`);
96
+ throw new errors_1.ValidationError(`length of ${name} may not be less than ${length}`);
97
97
  }
98
98
  }
99
99
  exports.minLength = minLength;
@@ -106,7 +106,7 @@ exports.minLength = minLength;
106
106
  */
107
107
  function isNumber(name, o) {
108
108
  if (o !== undefined && o !== null && isNaN(Number(o))) {
109
- throw new validation_error_1.ValidationError(`${name} is not a number`);
109
+ throw new errors_1.ValidationError(`${name} is not a number`);
110
110
  }
111
111
  }
112
112
  exports.isNumber = isNumber;
@@ -124,7 +124,7 @@ function minValue(name, minValue, o) {
124
124
  isNumber(name, o);
125
125
  }
126
126
  if (+o < minValue) {
127
- throw new validation_error_1.ValidationError(`${name} may not be less than ${minValue}`);
127
+ throw new errors_1.ValidationError(`${name} may not be less than ${minValue}`);
128
128
  }
129
129
  }
130
130
  }
@@ -143,7 +143,7 @@ function maxValue(name, maxValue, o) {
143
143
  isNumber(name, o);
144
144
  }
145
145
  if (+o > maxValue) {
146
- throw new validation_error_1.ValidationError(`${name} may not be greater than ${maxValue}`);
146
+ throw new errors_1.ValidationError(`${name} may not be greater than ${maxValue}`);
147
147
  }
148
148
  }
149
149
  }
@@ -163,7 +163,7 @@ function betweenValues(name, minValue, maxValue, o) {
163
163
  isNumber(name, o);
164
164
  }
165
165
  if (+o < minValue || +o > maxValue) {
166
- throw new validation_error_1.ValidationError(`${name} must be between ${minValue} and ${maxValue}`);
166
+ throw new errors_1.ValidationError(`${name} must be between ${minValue} and ${maxValue}`);
167
167
  }
168
168
  }
169
169
  }
@@ -177,16 +177,16 @@ function validateString(options, value) {
177
177
  return;
178
178
  }
179
179
  if (!isString(value)) {
180
- throw new validation_error_1.ValidationError(`${options.name} must be a string`);
180
+ throw new errors_1.ValidationError(`${options.name} must be a string`);
181
181
  }
182
182
  if (options.minLength !== undefined && value.length < options.minLength) {
183
- throw new validation_error_1.ValidationError(`${options.name} must be at least ${options.minLength} characters`);
183
+ throw new errors_1.ValidationError(`${options.name} must be at least ${options.minLength} characters`);
184
184
  }
185
185
  if (options.maxLength !== undefined && value.length > options.maxLength) {
186
- throw new validation_error_1.ValidationError(`${options.name} must be at most ${options.maxLength} characters`);
186
+ throw new errors_1.ValidationError(`${options.name} must be at most ${options.maxLength} characters`);
187
187
  }
188
188
  if (options.regex !== undefined && !options.regex.test(value)) {
189
- throw new validation_error_1.ValidationError(`${options.name} must match ${options.regex}`);
189
+ throw new errors_1.ValidationError(`${options.name} must match ${options.regex}`);
190
190
  }
191
191
  if (options.notBlank !== undefined && options.notBlank) {
192
192
  notBlank(options.name, value);
@@ -1 +1 @@
1
- {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AAO,CAAC,QAAQ,EAAE;QACtD,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;KAC/B;IACD,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,OAAO,EAAE;QACpD,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;KAC9B;IACD,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,EAAE;QACtD,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;KAC/B;AACH,CAAC;AArCD,wCAqCC"}
@@ -1,19 +0,0 @@
1
- export type PossibleValidationError = {
2
- stack?: string;
3
- message?: string;
4
- name?: string;
5
- statusCode?: number;
6
- };
7
- /**
8
- * Checks if the given variable is a ValidationError.
9
- *
10
- * @param e the variable to check
11
- */
12
- export declare function isValidationError(e?: PossibleValidationError): e is ValidationError;
13
- /**
14
- * Thrown when a validation error occurs.
15
- */
16
- export declare class ValidationError extends Error {
17
- statusCode: number;
18
- constructor(message?: string, statusCode?: number);
19
- }
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValidationError = exports.isValidationError = void 0;
4
- /**
5
- * Checks if the given variable is a ValidationError.
6
- *
7
- * @param e the variable to check
8
- */
9
- function isValidationError(e) {
10
- return !!(e &&
11
- e.stack &&
12
- e.message &&
13
- e.statusCode &&
14
- e.name === 'ValidationError');
15
- }
16
- exports.isValidationError = isValidationError;
17
- /**
18
- * Thrown when a validation error occurs.
19
- */
20
- class ValidationError extends Error {
21
- constructor(message, statusCode) {
22
- super(message !== null && message !== void 0 ? message : 'Validation error');
23
- this.name = 'ValidationError';
24
- this.statusCode = statusCode !== null && statusCode !== void 0 ? statusCode : 400;
25
- }
26
- }
27
- exports.ValidationError = ValidationError;
28
- //# sourceMappingURL=validation-error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation-error.js","sourceRoot":"","sources":["validation-error.ts"],"names":[],"mappings":";;;AAOA;;;;GAIG;AACH,SAAgB,iBAAiB,CAC/B,CAA2B;IAE3B,OAAO,CAAC,CAAC,CACP,CAAC;QACD,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,IAAI,KAAK,iBAAiB,CAC7B,CAAC;AACJ,CAAC;AAVD,8CAUC;AAED;;GAEG;AACH,MAAa,eAAgB,SAAQ,KAAK;IAGxC,YAAY,OAAgB,EAAE,UAAmB;QAC/C,KAAK,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,kBAAkB,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,GAAG,CAAC;IACtC,CAAC;CACF;AARD,0CAQC"}