@nestjs/common 10.4.10 → 10.4.11
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.
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IntrinsicException = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Exception that represents an intrinsic error in the application.
|
|
6
|
-
* When thrown, the default exception filter will not log the error message.
|
|
7
|
-
*
|
|
8
|
-
* @publicApi
|
|
9
|
-
*/
|
|
10
|
-
class IntrinsicException extends Error {
|
|
11
|
-
}
|
|
12
|
-
exports.IntrinsicException = IntrinsicException;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
2
|
-
import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
|
|
3
|
-
export interface ParseDatePipeOptions {
|
|
4
|
-
/**
|
|
5
|
-
* If true, the pipe will return null or undefined if the value is not provided
|
|
6
|
-
* @default false
|
|
7
|
-
*/
|
|
8
|
-
optional?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Default value for the date
|
|
11
|
-
*/
|
|
12
|
-
default?: () => Date;
|
|
13
|
-
/**
|
|
14
|
-
* The HTTP status code to be used in the response when the validation fails.
|
|
15
|
-
*/
|
|
16
|
-
errorHttpStatusCode?: ErrorHttpStatusCode;
|
|
17
|
-
/**
|
|
18
|
-
* A factory function that returns an exception object to be thrown
|
|
19
|
-
* if validation fails.
|
|
20
|
-
* @param error Error message
|
|
21
|
-
* @returns The exception object
|
|
22
|
-
*/
|
|
23
|
-
exceptionFactory?: (error: string) => any;
|
|
24
|
-
}
|
|
25
|
-
export declare class ParseDatePipe implements PipeTransform<string | number | undefined | null> {
|
|
26
|
-
private readonly options;
|
|
27
|
-
protected exceptionFactory: (error: string) => any;
|
|
28
|
-
constructor(options?: ParseDatePipeOptions);
|
|
29
|
-
/**
|
|
30
|
-
* Method that accesses and performs optional transformation on argument for
|
|
31
|
-
* in-flight requests.
|
|
32
|
-
*
|
|
33
|
-
* @param value currently processed route argument
|
|
34
|
-
* @param metadata contains metadata about the currently processed route argument
|
|
35
|
-
*/
|
|
36
|
-
transform(value: string | number | undefined | null): Date | null | undefined;
|
|
37
|
-
}
|
package/pipes/parse-date.pipe.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParseDatePipe = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const injectable_decorator_1 = require("../decorators/core/injectable.decorator");
|
|
6
|
-
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
7
|
-
const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
|
|
8
|
-
const shared_utils_1 = require("../utils/shared.utils");
|
|
9
|
-
let ParseDatePipe = class ParseDatePipe {
|
|
10
|
-
constructor(options = {}) {
|
|
11
|
-
this.options = options;
|
|
12
|
-
const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST } = options;
|
|
13
|
-
this.exceptionFactory =
|
|
14
|
-
exceptionFactory ||
|
|
15
|
-
(error => new http_error_by_code_util_1.HttpErrorByCode[errorHttpStatusCode](error));
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Method that accesses and performs optional transformation on argument for
|
|
19
|
-
* in-flight requests.
|
|
20
|
-
*
|
|
21
|
-
* @param value currently processed route argument
|
|
22
|
-
* @param metadata contains metadata about the currently processed route argument
|
|
23
|
-
*/
|
|
24
|
-
transform(value) {
|
|
25
|
-
if (this.options.optional && (0, shared_utils_1.isNil)(value)) {
|
|
26
|
-
return this.options.default ? this.options.default() : value;
|
|
27
|
-
}
|
|
28
|
-
if (!value) {
|
|
29
|
-
throw this.exceptionFactory('Validation failed (no Date provided)');
|
|
30
|
-
}
|
|
31
|
-
const transformedValue = new Date(value);
|
|
32
|
-
if (isNaN(transformedValue.getTime())) {
|
|
33
|
-
throw this.exceptionFactory('Validation failed (invalid date format)');
|
|
34
|
-
}
|
|
35
|
-
return transformedValue;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
exports.ParseDatePipe = ParseDatePipe;
|
|
39
|
-
exports.ParseDatePipe = ParseDatePipe = tslib_1.__decorate([
|
|
40
|
-
(0, injectable_decorator_1.Injectable)(),
|
|
41
|
-
tslib_1.__metadata("design:paramtypes", [Object])
|
|
42
|
-
], ParseDatePipe);
|