@nestjs/mapped-types
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -6,2 +6,2 @@ export * from './intersection-type.helper'; | ||
export * from './pick-type.helper'; | ||
export { applyIsOptionalDecorator, inheritPropertyInitializers, inheritTransformationMetadata, inheritValidationMetadata, } from './type-helpers.utils'; | ||
export { applyIsOptionalDecorator, applyValidateIfDefinedDecorator, inheritPropertyInitializers, inheritTransformationMetadata, inheritValidationMetadata, } from './type-helpers.utils'; |
@@ -17,3 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.inheritValidationMetadata = exports.inheritTransformationMetadata = exports.inheritPropertyInitializers = exports.applyIsOptionalDecorator = void 0; | ||
exports.inheritValidationMetadata = exports.inheritTransformationMetadata = exports.inheritPropertyInitializers = exports.applyValidateIfDefinedDecorator = exports.applyIsOptionalDecorator = void 0; | ||
__exportStar(require("./intersection-type.helper"), exports); | ||
@@ -26,4 +26,5 @@ __exportStar(require("./mapped-type.interface"), exports); | ||
Object.defineProperty(exports, "applyIsOptionalDecorator", { enumerable: true, get: function () { return type_helpers_utils_1.applyIsOptionalDecorator; } }); | ||
Object.defineProperty(exports, "applyValidateIfDefinedDecorator", { enumerable: true, get: function () { return type_helpers_utils_1.applyValidateIfDefinedDecorator; } }); | ||
Object.defineProperty(exports, "inheritPropertyInitializers", { enumerable: true, get: function () { return type_helpers_utils_1.inheritPropertyInitializers; } }); | ||
Object.defineProperty(exports, "inheritTransformationMetadata", { enumerable: true, get: function () { return type_helpers_utils_1.inheritTransformationMetadata; } }); | ||
Object.defineProperty(exports, "inheritValidationMetadata", { enumerable: true, get: function () { return type_helpers_utils_1.inheritValidationMetadata; } }); |
import { Type } from '@nestjs/common'; | ||
import { MappedType } from './mapped-type.interface'; | ||
import { RemoveFieldsWithType } from './types/remove-fields-with-type.type'; | ||
export declare function PartialType<T>(classRef: Type<T>): MappedType<RemoveFieldsWithType<Partial<T>, Function>>; | ||
export declare function PartialType<T>(classRef: Type<T>, options?: { | ||
skipNullProperties?: boolean; | ||
}): MappedType<RemoveFieldsWithType<Partial<T>, Function>>; |
@@ -5,3 +5,3 @@ "use strict"; | ||
const type_helpers_utils_1 = require("./type-helpers.utils"); | ||
function PartialType(classRef) { | ||
function PartialType(classRef, options = {}) { | ||
class PartialClassType { | ||
@@ -16,3 +16,5 @@ constructor() { | ||
propertyKeys.forEach((key) => { | ||
(0, type_helpers_utils_1.applyIsOptionalDecorator)(PartialClassType, key); | ||
options.skipNullProperties === false | ||
? (0, type_helpers_utils_1.applyValidateIfDefinedDecorator)(PartialClassType, key) | ||
: (0, type_helpers_utils_1.applyIsOptionalDecorator)(PartialClassType, key); | ||
}); | ||
@@ -19,0 +21,0 @@ } |
import { Type } from '@nestjs/common'; | ||
export declare function applyIsOptionalDecorator(targetClass: Function, propertyKey: string): void; | ||
export declare function applyValidateIfDefinedDecorator(targetClass: Function, propertyKey: string): void; | ||
export declare function inheritValidationMetadata(parentClass: Type<any>, targetClass: Function, isPropertyInherited?: (key: string) => boolean): string[] | undefined; | ||
export declare function inheritTransformationMetadata(parentClass: Type<any>, targetClass: Function, isPropertyInherited?: (key: string) => boolean): void; | ||
export declare function inheritPropertyInitializers(target: Record<string, any>, sourceClass: Type<any>, isPropertyInherited?: (key: string) => boolean): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.inheritPropertyInitializers = exports.inheritTransformationMetadata = exports.inheritValidationMetadata = exports.applyIsOptionalDecorator = void 0; | ||
exports.inheritPropertyInitializers = exports.inheritTransformationMetadata = exports.inheritValidationMetadata = exports.applyValidateIfDefinedDecorator = exports.applyIsOptionalDecorator = void 0; | ||
const common_1 = require("@nestjs/common"); | ||
@@ -15,2 +15,11 @@ const logger = new common_1.Logger('MappedTypes'); | ||
exports.applyIsOptionalDecorator = applyIsOptionalDecorator; | ||
function applyValidateIfDefinedDecorator(targetClass, propertyKey) { | ||
if (!isClassValidatorAvailable()) { | ||
return; | ||
} | ||
const classValidator = require('class-validator'); | ||
const decoratorFactory = classValidator.ValidateIf((_, value) => value !== undefined); | ||
decoratorFactory(targetClass.prototype, propertyKey); | ||
} | ||
exports.applyValidateIfDefinedDecorator = applyValidateIfDefinedDecorator; | ||
function inheritValidationMetadata(parentClass, targetClass, isPropertyInherited) { | ||
@@ -17,0 +26,0 @@ if (!isClassValidatorAvailable()) { |
{ | ||
"name": "@nestjs/mapped-types", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@mapped-types)", | ||
@@ -23,23 +23,23 @@ "author": "Kamil Mysliwiec", | ||
"devDependencies": { | ||
"@commitlint/cli": "18.4.1", | ||
"@commitlint/config-angular": "18.4.0", | ||
"@nestjs/common": "10.2.8", | ||
"@types/jest": "29.5.8", | ||
"@types/node": "20.9.0", | ||
"@typescript-eslint/eslint-plugin": "6.11.0", | ||
"@typescript-eslint/parser": "6.11.0", | ||
"@commitlint/cli": "18.6.0", | ||
"@commitlint/config-angular": "18.6.0", | ||
"@nestjs/common": "10.3.2", | ||
"@types/jest": "29.5.12", | ||
"@types/node": "20.11.16", | ||
"@typescript-eslint/eslint-plugin": "6.21.0", | ||
"@typescript-eslint/parser": "6.21.0", | ||
"class-transformer": "0.5.1", | ||
"class-validator": "0.14.0", | ||
"eslint": "8.53.0", | ||
"eslint-config-prettier": "9.0.0", | ||
"eslint-plugin-import": "2.29.0", | ||
"husky": "8.0.3", | ||
"class-validator": "0.14.1", | ||
"eslint": "8.56.0", | ||
"eslint-config-prettier": "9.1.0", | ||
"eslint-plugin-import": "2.29.1", | ||
"husky": "9.0.10", | ||
"jest": "29.7.0", | ||
"lint-staged": "15.1.0", | ||
"prettier": "3.1.0", | ||
"reflect-metadata": "0.1.13", | ||
"release-it": "17.0.0", | ||
"lint-staged": "15.2.2", | ||
"prettier": "3.2.5", | ||
"reflect-metadata": "0.2.1", | ||
"release-it": "17.0.3", | ||
"rimraf": "5.0.5", | ||
"ts-jest": "29.1.1", | ||
"typescript": "5.2.2" | ||
"ts-jest": "29.1.2", | ||
"typescript": "5.3.3" | ||
}, | ||
@@ -50,3 +50,3 @@ "peerDependencies": { | ||
"class-validator": "^0.13.0 || ^0.14.0", | ||
"reflect-metadata": "^0.1.12" | ||
"reflect-metadata": "^0.1.12 || ^0.2.0" | ||
}, | ||
@@ -53,0 +53,0 @@ "peerDependenciesMeta": { |
24445
383