ajout du modèle DTO pour users, et d'une liste blanche pour empêcher les payload malicieux

This commit is contained in:
batche
2022-10-24 14:15:46 +02:00
parent b12db3e912
commit 5396cce993
2334 changed files with 95831 additions and 23 deletions

View File

@@ -1,9 +1,15 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@nestjs/core"); const core_1 = require("@nestjs/core");
const common_1 = require("@nestjs/common");
const app_module_1 = require("./app.module"); const app_module_1 = require("./app.module");
async function bootstrap() { async function bootstrap() {
const app = await core_1.NestFactory.create(app_module_1.AppModule); const app = await core_1.NestFactory.create(app_module_1.AppModule);
app.useGlobalPipes(new common_1.ValidationPipe({
whitelist: true,
forbidNonWhitelisted: true,
transform: true,
}));
await app.listen(3000); await app.listen(3000);
} }
bootstrap(); bootstrap();

View File

@@ -1 +1 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IAEtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AACD,SAAS,EAAE,CAAC"} {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,2CAAgD;AAChD,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IAEtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAGhD,GAAG,CAAC,cAAc,CACnB,IAAI,uBAAc,CAAC;QAElB,SAAS,EAAE,IAAI;QAEf,oBAAoB,EAAE,IAAI;QAE1B,SAAS,EAAE,IAAI;KACf,CAAC,CACA,CAAC;IACF,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AACD,SAAS,EAAE,CAAC"}

View File

@@ -0,0 +1,2 @@
export declare class UpdateUsersDto {
}

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdateUsersDto = void 0;
class UpdateUsersDto {
}
exports.UpdateUsersDto = UpdateUsersDto;
//# sourceMappingURL=update-users.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"update-users.dto.js","sourceRoot":"","sources":["../../../../src/src/users/dto/update-users.dto.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAc;CAAG;AAA9B,wCAA8B"}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
export declare class CreatUsersDto {
userId: string;
username: string;
password: string;
}

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreatUsersDto = void 0;
class CreatUsersDto {
}
exports.CreatUsersDto = CreatUsersDto;
//# sourceMappingURL=creat-users.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"creat-users.dto.js","sourceRoot":"","sources":["../../../src/users/dto/creat-users.dto.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAa;CAIzB;AAJD,sCAIC"}

View File

@@ -0,0 +1,5 @@
export declare class CreateUsersDto {
readonly name: string;
readonly username: string;
readonly password: string;
}

View File

@@ -0,0 +1,29 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateUsersDto = void 0;
const class_validator_1 = require("class-validator");
class CreateUsersDto {
}
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateUsersDto.prototype, "name", void 0);
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateUsersDto.prototype, "username", void 0);
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateUsersDto.prototype, "password", void 0);
exports.CreateUsersDto = CreateUsersDto;
//# sourceMappingURL=create-users.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"create-users.dto.js","sourceRoot":"","sources":["../../../src/users/dto/create-users.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA2C;AAE3C,MAAa,cAAc;CAO1B;AANA;IAAC,IAAA,0BAAQ,GAAE;;4CACW;AACtB;IAAC,IAAA,0BAAQ,GAAE;;gDACe;AAC1B;IAAC,IAAA,0BAAQ,GAAE;;gDACe;AAN3B,wCAOC"}

View File

@@ -0,0 +1,5 @@
import { CreateUsersDto } from "./create-users.dto";
declare const UpdateUsersDto_base: import("@nestjs/mapped-types").MappedType<Partial<CreateUsersDto>>;
export declare class UpdateUsersDto extends UpdateUsersDto_base {
}
export {};

View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdateUsersDto = void 0;
const mapped_types_1 = require("@nestjs/mapped-types");
const create_users_dto_1 = require("./create-users.dto");
class UpdateUsersDto extends (0, mapped_types_1.PartialType)(create_users_dto_1.CreateUsersDto) {
}
exports.UpdateUsersDto = UpdateUsersDto;
//# sourceMappingURL=update-users.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"update-users.dto.js","sourceRoot":"","sources":["../../../src/users/dto/update-users.dto.ts"],"names":[],"mappings":";;;AAIA,uDAAmD;AACnD,yDAAoD;AAEpD,MAAa,cAAe,SAAQ,IAAA,0BAAW,EAAC,iCAAc,CAAC;CAAE;AAAjE,wCAAiE"}

View File

@@ -1,5 +1,6 @@
export declare class User { export declare class User {
userId: string; userId: string;
name: string;
username: string; username: string;
password: string; password: string;
} }

View File

@@ -1 +1 @@
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../src/users/entities/user.entity.ts"],"names":[],"mappings":";;;AAAA,MAAa,IAAI;CAIhB;AAJD,oBAIC"} {"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../src/users/entities/user.entity.ts"],"names":[],"mappings":";;;AAAA,MAAa,IAAI;CAKhB;AALD,oBAKC"}

View File

@@ -1,10 +1,12 @@
import { CreateUsersDto } from './dto/create-users.dto';
import { UpdateUsersDto } from './dto/update-users.dto';
import { UsersService } from './users.service'; import { UsersService } from './users.service';
export declare class UsersController { export declare class UsersController {
private readonly usersService; private readonly usersService;
constructor(usersService: UsersService); constructor(usersService: UsersService);
findAll(query: any): import("./entities/user.entity").User[]; findAll(query: any): import("./entities/user.entity").User[];
findOne(id: string): import("./entities/user.entity").User; findOne(id: string): import("./entities/user.entity").User;
create(body: any): string; create(createUsersDto: CreateUsersDto): string;
update(id: string, body: any): string; update(id: string, usersUpdateDto: UpdateUsersDto): string;
remove(id: string): string; remove(id: string): string;
} }

View File

@@ -14,6 +14,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.UsersController = void 0; exports.UsersController = void 0;
const common_1 = require("@nestjs/common"); const common_1 = require("@nestjs/common");
const create_users_dto_1 = require("./dto/create-users.dto");
const update_users_dto_1 = require("./dto/update-users.dto");
const users_service_1 = require("./users.service"); const users_service_1 = require("./users.service");
let UsersController = class UsersController { let UsersController = class UsersController {
constructor(usersService) { constructor(usersService) {
@@ -25,11 +27,11 @@ let UsersController = class UsersController {
findOne(id) { findOne(id) {
return this.usersService.findOne(id); return this.usersService.findOne(id);
} }
create(body) { create(createUsersDto) {
return this.usersService.create(body); return this.usersService.create(createUsersDto);
} }
update(id, body) { update(id, usersUpdateDto) {
return this.usersService.update(id, body); return this.usersService.update(id, usersUpdateDto);
} }
remove(id) { remove(id) {
return this.usersService.remove(id); return this.usersService.remove(id);
@@ -54,7 +56,7 @@ __decorate([
(0, common_1.HttpCode)(common_1.HttpStatus.GONE), (0, common_1.HttpCode)(common_1.HttpStatus.GONE),
__param(0, (0, common_1.Body)()), __param(0, (0, common_1.Body)()),
__metadata("design:type", Function), __metadata("design:type", Function),
__metadata("design:paramtypes", [Object]), __metadata("design:paramtypes", [create_users_dto_1.CreateUsersDto]),
__metadata("design:returntype", void 0) __metadata("design:returntype", void 0)
], UsersController.prototype, "create", null); ], UsersController.prototype, "create", null);
__decorate([ __decorate([
@@ -62,7 +64,7 @@ __decorate([
__param(0, (0, common_1.Param)('id')), __param(0, (0, common_1.Param)('id')),
__param(1, (0, common_1.Body)()), __param(1, (0, common_1.Body)()),
__metadata("design:type", Function), __metadata("design:type", Function),
__metadata("design:paramtypes", [String, Object]), __metadata("design:paramtypes", [String, update_users_dto_1.UpdateUsersDto]),
__metadata("design:returntype", void 0) __metadata("design:returntype", void 0)
], UsersController.prototype, "update", null); ], UsersController.prototype, "update", null);
__decorate([ __decorate([

View File

@@ -1 +1 @@
{"version":3,"file":"users.controller.js","sourceRoot":"","sources":["../../src/users/users.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAGwB;AAExB,mDAA+C;AAGxC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC3B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAG3D,OAAO,CAAU,KAAK;QAErB,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IACpC,CAAC;IAGD,OAAO,CAAc,EAAU;QAC9B,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;IAID,MAAM,CAAS,IAAI;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC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 'john', name: 'John',
username: 'TheBoss',
password: 'changeme', password: 'changeme',
}, },
{ {
userId: '2', userId: '2',
username: 'maria', name: 'Jane',
username: 'Jane2000',
password: 'guess', password: 'guess',
}, },
]; ];
@@ -38,7 +40,7 @@ let UsersService = class UsersService {
const user = this.users.push(createUserDto); const user = this.users.push(createUserDto);
if (!user) if (!user)
throw new common_1.HttpException(`The user could not be created.`, common_1.HttpStatus.NOT_FOUND); throw new common_1.HttpException(`The user could not be created.`, common_1.HttpStatus.NOT_FOUND);
return 'User has been created'; return createUserDto.username + ' has been created';
} }
update(id, updateUserDto) { update(id, updateUserDto) {
const index = this.users.findIndex(user => user.userId === id); const index = this.users.findIndex(user => user.userId === id);

View File

@@ -1 +1 @@
{"version":3,"file":"users.service.js","sourceRoot":"","sources":["../../src/users/users.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAsG;AAK/F,IAAM,YAAY,GAAlB,MAAM,YAAY;IAAlB;QACE,UAAK,GAAU;YACtB;gBACC,MAAM,EAAE,GAAG;gBACX,QAAQ,EAAE,MAAM;gBAChB,QAAQ,EAAE,UAAU;aACpB;YACD;gBACC,MAAM,EAAE,GAAG;gBACX,QAAQ,EAAE,OAAO;gBACjB,QAAQ,EAAE,OAAO;aACjB;SACD,CAAC;IAkCH,CAAC;IAhCA,OAAO,CAAC,EAAU;QACjB,MAAM,IAAI,GAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,0BAAiB,CAAC,+BAA+B,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO;QACN,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM;YACrB,MAAM,IAAI,sBAAa,CAAC,iBAAiB,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC,KAA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C,IAAI,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC5B,OAAO,uBAAuB,CAAC;IAChC,CAAC;CAED,CAAA;AAhDY,YAAY;IADxB,IAAA,mBAAU,GAAE;GACA,YAAY,CAgDxB;AAhDY,oCAAY"}

View File

@@ -0,0 +1,2 @@
export declare class CreatUsersDto {
}

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreatUsersDto = void 0;
class CreatUsersDto {
}
exports.CreatUsersDto = CreatUsersDto;
//# sourceMappingURL=creat-users.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"creat-users.dto.js","sourceRoot":"","sources":["../../../../src/users/users/dto/creat-users.dto.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAa;CAAG;AAA7B,sCAA6B"}

View File

@@ -0,0 +1,4 @@
export declare class CreateUsersDto {
readonly username: string;
readonly password: string;
}

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateUsersDto = void 0;
class CreateUsersDto {
}
exports.CreateUsersDto = CreateUsersDto;
//# sourceMappingURL=create-users.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"create-users.dto.js","sourceRoot":"","sources":["../../../../src/users/users/dto/create-users.dto.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAc;CAG1B;AAHD,wCAGC"}

View File

@@ -1505,6 +1505,25 @@
} }
} }
}, },
"node_modules/@nestjs/mapped-types": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-1.2.0.tgz",
"integrity": "sha512-NTFwPZkQWsArQH8QSyFWGZvJ08gR+R4TofglqZoihn/vU+ktHEJjMqsIsADwb7XD97DhiD+TVv5ac+jG33BHrg==",
"peerDependencies": {
"@nestjs/common": "^7.0.8 || ^8.0.0 || ^9.0.0",
"class-transformer": "^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0",
"class-validator": "^0.11.1 || ^0.12.0 || ^0.13.0",
"reflect-metadata": "^0.1.12"
},
"peerDependenciesMeta": {
"class-transformer": {
"optional": true
},
"class-validator": {
"optional": true
}
}
},
"node_modules/@nestjs/passport": { "node_modules/@nestjs/passport": {
"version": "9.0.0", "version": "9.0.0",
"resolved": "https://registry.npmjs.org/@nestjs/passport/-/passport-9.0.0.tgz", "resolved": "https://registry.npmjs.org/@nestjs/passport/-/passport-9.0.0.tgz",
@@ -2043,6 +2062,11 @@
"@types/superagent": "*" "@types/superagent": "*"
} }
}, },
"node_modules/@types/validator": {
"version": "13.7.9",
"resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.7.9.tgz",
"integrity": "sha512-y5KJ1PjGXPpU4CZ7lThDu31s+FqvzhqwMOR6Go/x6xaQMFjgzwfzfOvCwABsylr/5n8sB1qFQm1Vi7TaCB8P+A=="
},
"node_modules/@types/yargs": { "node_modules/@types/yargs": {
"version": "17.0.13", "version": "17.0.13",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.13.tgz", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.13.tgz",
@@ -3043,6 +3067,20 @@
"integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==", "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==",
"dev": true "dev": true
}, },
"node_modules/class-transformer": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz",
"integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw=="
},
"node_modules/class-validator": {
"version": "0.13.2",
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.13.2.tgz",
"integrity": "sha512-yBUcQy07FPlGzUjoLuUfIOXzgynnQPPruyK1Ge2B74k9ROwnle1E+NxLWnUv5OLU8hA/qL5leAE9XnXq3byaBw==",
"dependencies": {
"libphonenumber-js": "^1.9.43",
"validator": "^13.7.0"
}
},
"node_modules/cli-cursor": { "node_modules/cli-cursor": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz",
@@ -5786,6 +5824,11 @@
"node": ">= 0.8.0" "node": ">= 0.8.0"
} }
}, },
"node_modules/libphonenumber-js": {
"version": "1.10.14",
"resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.14.tgz",
"integrity": "sha512-McGS7GV/WjJ2KjfOGhJU1oJn29RYeo7Q+RpANRbUNMQ9gj5XArpbjurSuyYPTejFwbaUojstQ4XyWCrAzGOUXw=="
},
"node_modules/lines-and-columns": { "node_modules/lines-and-columns": {
"version": "1.2.4", "version": "1.2.4",
"resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz",
@@ -8034,6 +8077,14 @@
"node": ">=10.12.0" "node": ">=10.12.0"
} }
}, },
"node_modules/validator": {
"version": "13.7.0",
"resolved": "https://registry.npmjs.org/validator/-/validator-13.7.0.tgz",
"integrity": "sha512-nYXQLCBkpJ8X6ltALua9dRrZDHVYxjJ1wgskNt1lH9fzGjs3tgojGSCBjmEPwkWS1y29+DrizMTW19Pr9uB2nw==",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/vary": { "node_modules/vary": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",

View File

@@ -0,0 +1,28 @@
{
"extends": ["@commitlint/config-angular"],
"rules": {
"subject-case": [
2,
"always",
["sentence-case", "start-case", "pascal-case", "upper-case", "lower-case"]
],
"type-enum": [
2,
"always",
[
"build",
"chore",
"ci",
"docs",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test",
"sample"
]
]
}
}

View File

@@ -0,0 +1,3 @@
src/**/*.test.ts
src/**/files/**
test/**

View File

@@ -0,0 +1,28 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/@typescript-eslint',
],
root: true,
env: {
node: true,
jest: true,
},
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-types': 'off'
},
};

View File

@@ -0,0 +1,8 @@
{
"git": {
"commitMessage": "chore(): release v${version}"
},
"github": {
"release": true
}
}

View File

@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) Kamil Mysliwiec
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,70 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
</p>
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
[travis-url]: https://travis-ci.org/nestjs/nest
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
[linux-url]: https://travis-ci.org/nestjs/nest
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-dc3d53.svg"/></a>
<a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
## Description
Mapped Types module for [Nest](https://github.com/nestjs/nest) used by the `@nestjs/graphql` and `@nestjs/swagger` packages.
## Installation
```bash
$ npm i --save @nestjs/mapped-types
```
## Quick Start
As you build out features, it's often useful to construct variants on a base entity type. A good example of such a variant is a **Data Transfer Object** (DTO). A Data Transfer Object is an object that is used to encapsulate data, and send it from one part of your application to another. DTOs help us define the input and output interfaces of our system.
Let's imagine a real-world example, where we typically need to build both a **create** and **update** variations for the same entity type.
The create variant may require all fields, while the update variant may make all fields **optional**. Not to mention, both these types can also be variants of an entity type (to some extent).
That's a lot of redundant code!
Thus, [NestJS](https://github.com/nestjs/nest) now provides several utility functions that perform type transformations to help us avoid doing this, and make life a little bit easier.
Available mapped types:
- `PartialType` - returns a type (class) with all the properties of the input type set to optional (requirement: at least 1 validation decorator applied to each property)
- `PickType` - constructs a new type (class) by picking a set of properties from an input type
- `OmitType` - constructs a type by picking all properties from an input type and then removing a particular set of keys
- `IntersectionType` - combines two types into one new type (class)
Read more in [this article](https://trilon.io/blog/introducing-mapped-types-for-nestjs).
## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
## Stay in touch
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
## License
Nest is [MIT licensed](LICENSE).

View File

@@ -0,0 +1,6 @@
export * from './intersection-type.helper';
export * from './mapped-type.interface';
export * from './omit-type.helper';
export * from './partial-type.helper';
export * from './pick-type.helper';
export { applyIsOptionalDecorator, inheritPropertyInitializers, inheritTransformationMetadata, inheritValidationMetadata, } from './type-helpers.utils';

View File

@@ -0,0 +1,23 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.inheritValidationMetadata = exports.inheritTransformationMetadata = exports.inheritPropertyInitializers = exports.applyIsOptionalDecorator = void 0;
__exportStar(require("./intersection-type.helper"), exports);
__exportStar(require("./mapped-type.interface"), exports);
__exportStar(require("./omit-type.helper"), exports);
__exportStar(require("./partial-type.helper"), exports);
__exportStar(require("./pick-type.helper"), exports);
var type_helpers_utils_1 = require("./type-helpers.utils");
Object.defineProperty(exports, "applyIsOptionalDecorator", { enumerable: true, get: function () { return type_helpers_utils_1.applyIsOptionalDecorator; } });
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; } });

View File

@@ -0,0 +1,9 @@
import { Type } from '@nestjs/common';
import { MappedType } from './mapped-type.interface';
declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
declare type ClassRefsToConstructors<T extends Type[]> = {
[U in keyof T]: T[U] extends Type<infer V> ? V : never;
};
declare type Intersection<T extends Type[]> = MappedType<UnionToIntersection<ClassRefsToConstructors<T>[number]>>;
export declare function IntersectionType<T extends Type[]>(...classRefs: T): Intersection<T>;
export {};

View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IntersectionType = void 0;
const type_helpers_utils_1 = require("./type-helpers.utils");
function IntersectionType(...classRefs) {
class IntersectionClassType {
constructor() {
classRefs.forEach((classRef) => {
(0, type_helpers_utils_1.inheritPropertyInitializers)(this, classRef);
});
}
}
classRefs.forEach((classRef) => {
(0, type_helpers_utils_1.inheritValidationMetadata)(classRef, IntersectionClassType);
(0, type_helpers_utils_1.inheritTransformationMetadata)(classRef, IntersectionClassType);
});
const intersectedNames = classRefs.reduce((prev, ref) => prev + ref.name, '');
Object.defineProperty(IntersectionClassType, 'name', {
value: `Intersection${intersectedNames}`,
});
return IntersectionClassType;
}
exports.IntersectionType = IntersectionType;

View File

@@ -0,0 +1,4 @@
import { Type } from '@nestjs/common';
export interface MappedType<T> extends Type<T> {
new (): T;
}

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,3 @@
import { Type } from '@nestjs/common';
import { MappedType } from './mapped-type.interface';
export declare function OmitType<T, K extends keyof T>(classRef: Type<T>, keys: readonly K[]): MappedType<Omit<T, typeof keys[number]>>;

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OmitType = void 0;
const type_helpers_utils_1 = require("./type-helpers.utils");
function OmitType(classRef, keys) {
const isInheritedPredicate = (propertyKey) => !keys.includes(propertyKey);
class OmitClassType {
constructor() {
(0, type_helpers_utils_1.inheritPropertyInitializers)(this, classRef, isInheritedPredicate);
}
}
(0, type_helpers_utils_1.inheritValidationMetadata)(classRef, OmitClassType, isInheritedPredicate);
(0, type_helpers_utils_1.inheritTransformationMetadata)(classRef, OmitClassType, isInheritedPredicate);
return OmitClassType;
}
exports.OmitType = OmitType;

View File

@@ -0,0 +1,3 @@
import { Type } from '@nestjs/common';
import { MappedType } from './mapped-type.interface';
export declare function PartialType<T>(classRef: Type<T>): MappedType<Partial<T>>;

View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PartialType = void 0;
const type_helpers_utils_1 = require("./type-helpers.utils");
function PartialType(classRef) {
class PartialClassType {
constructor() {
(0, type_helpers_utils_1.inheritPropertyInitializers)(this, classRef);
}
}
const propertyKeys = (0, type_helpers_utils_1.inheritValidationMetadata)(classRef, PartialClassType);
(0, type_helpers_utils_1.inheritTransformationMetadata)(classRef, PartialClassType);
if (propertyKeys) {
propertyKeys.forEach((key) => {
(0, type_helpers_utils_1.applyIsOptionalDecorator)(PartialClassType, key);
});
}
Object.defineProperty(PartialClassType, 'name', {
value: `Partial${classRef.name}`,
});
return PartialClassType;
}
exports.PartialType = PartialType;

View File

@@ -0,0 +1,3 @@
import { Type } from '@nestjs/common';
import { MappedType } from './mapped-type.interface';
export declare function PickType<T, K extends keyof T>(classRef: Type<T>, keys: readonly K[]): MappedType<Pick<T, typeof keys[number]>>;

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PickType = void 0;
const type_helpers_utils_1 = require("./type-helpers.utils");
function PickType(classRef, keys) {
const isInheritedPredicate = (propertyKey) => keys.includes(propertyKey);
class PickClassType {
constructor() {
(0, type_helpers_utils_1.inheritPropertyInitializers)(this, classRef, isInheritedPredicate);
}
}
(0, type_helpers_utils_1.inheritValidationMetadata)(classRef, PickClassType, isInheritedPredicate);
(0, type_helpers_utils_1.inheritTransformationMetadata)(classRef, PickClassType, isInheritedPredicate);
return PickClassType;
}
exports.PickType = PickType;

View File

@@ -0,0 +1,5 @@
import { Type } from '@nestjs/common';
export declare function applyIsOptionalDecorator(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;

View File

@@ -0,0 +1,127 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.inheritPropertyInitializers = exports.inheritTransformationMetadata = exports.inheritValidationMetadata = exports.applyIsOptionalDecorator = void 0;
const common_1 = require("@nestjs/common");
const logger = new common_1.Logger('MappedTypes');
function applyIsOptionalDecorator(targetClass, propertyKey) {
if (!isClassValidatorAvailable()) {
return;
}
const classValidator = require('class-validator');
const decoratorFactory = classValidator.IsOptional();
decoratorFactory(targetClass.prototype, propertyKey);
}
exports.applyIsOptionalDecorator = applyIsOptionalDecorator;
function inheritValidationMetadata(parentClass, targetClass, isPropertyInherited) {
if (!isClassValidatorAvailable()) {
return;
}
try {
const classValidator = require('class-validator');
const metadataStorage = classValidator.getMetadataStorage
? classValidator.getMetadataStorage()
: classValidator.getFromContainer(classValidator.MetadataStorage);
const getTargetValidationMetadatasArgs = [parentClass, null, false, false];
const targetMetadata = metadataStorage.getTargetValidationMetadatas(...getTargetValidationMetadatasArgs);
return targetMetadata
.filter(({ propertyName }) => !isPropertyInherited || isPropertyInherited(propertyName))
.map((value) => {
const originalType = Reflect.getMetadata('design:type', parentClass.prototype, value.propertyName);
if (originalType) {
Reflect.defineMetadata('design:type', originalType, targetClass.prototype, value.propertyName);
}
metadataStorage.addValidationMetadata(Object.assign(Object.assign({}, value), { target: targetClass }));
return value.propertyName;
});
}
catch (err) {
logger.error(`Validation ("class-validator") metadata cannot be inherited for "${parentClass.name}" class.`);
logger.error(err);
}
}
exports.inheritValidationMetadata = inheritValidationMetadata;
function inheritTransformationMetadata(parentClass, targetClass, isPropertyInherited) {
if (!isClassTransformerAvailable()) {
return;
}
try {
const transformMetadataKeys = [
'_excludeMetadatas',
'_exposeMetadatas',
'_transformMetadatas',
'_typeMetadatas',
];
transformMetadataKeys.forEach((key) => inheritTransformerMetadata(key, parentClass, targetClass, isPropertyInherited));
}
catch (err) {
logger.error(`Transformer ("class-transformer") metadata cannot be inherited for "${parentClass.name}" class.`);
logger.error(err);
}
}
exports.inheritTransformationMetadata = inheritTransformationMetadata;
function inheritTransformerMetadata(key, parentClass, targetClass, isPropertyInherited) {
let classTransformer;
try {
classTransformer = require('class-transformer/cjs/storage');
}
catch (_a) {
classTransformer = require('class-transformer/storage');
}
const metadataStorage = classTransformer.defaultMetadataStorage;
while (parentClass && parentClass !== Object) {
if (metadataStorage[key].has(parentClass)) {
const metadataMap = metadataStorage[key];
const parentMetadata = metadataMap.get(parentClass);
const targetMetadataEntries = Array.from(parentMetadata.entries())
.filter(([key]) => !isPropertyInherited || isPropertyInherited(key))
.map(([key, metadata]) => {
if (Array.isArray(metadata)) {
const targetMetadata = metadata.map((item) => (Object.assign(Object.assign({}, item), { target: targetClass })));
return [key, targetMetadata];
}
return [key, Object.assign(Object.assign({}, metadata), { target: targetClass })];
});
if (metadataMap.has(targetClass)) {
const existingRules = metadataMap.get(targetClass).entries();
metadataMap.set(targetClass, new Map([...existingRules, ...targetMetadataEntries]));
}
else {
metadataMap.set(targetClass, new Map(targetMetadataEntries));
}
}
parentClass = Object.getPrototypeOf(parentClass);
}
}
function isClassValidatorAvailable() {
try {
require('class-validator');
return true;
}
catch (_a) {
return false;
}
}
function isClassTransformerAvailable() {
try {
require('class-transformer');
return true;
}
catch (_a) {
return false;
}
}
function inheritPropertyInitializers(target, sourceClass, isPropertyInherited = (key) => true) {
try {
const tempInstance = new sourceClass();
const propertyNames = Object.getOwnPropertyNames(tempInstance);
propertyNames
.filter((propertyName) => typeof tempInstance[propertyName] !== 'undefined' &&
typeof target[propertyName] === 'undefined')
.filter((propertyName) => isPropertyInherited(propertyName))
.forEach((propertyName) => {
target[propertyName] = tempInstance[propertyName];
});
}
catch (_a) { }
}
exports.inheritPropertyInitializers = inheritPropertyInitializers;

View File

@@ -0,0 +1 @@
export * from './dist';

View File

@@ -0,0 +1,6 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
exports.__esModule = true;
__export(require("./dist"));

View File

@@ -0,0 +1,73 @@
{
"name": "@nestjs/mapped-types",
"version": "1.2.0",
"description": "Nest - modern, fast, powerful node.js web framework (@mapped-types)",
"author": "Kamil Mysliwiec",
"license": "MIT",
"url": "https://github.com/nestjs/mapped-types#readme",
"scripts": {
"build": "rimraf -rf dist && tsc -p tsconfig.json",
"lint": "eslint 'lib/**/*.ts' --fix",
"format": "prettier \"{lib,tests}/**/*.ts\" --write",
"prepublish:npm": "npm run build",
"publish:npm": "npm publish --access public",
"prepublish:next": "npm run build",
"publish:next": "npm publish --access public --tag next",
"test:e2e": "jest --config ./tests/jest-e2e.json --runInBand",
"test:e2e:dev": "jest --config ./tests/jest-e2e.json --runInBand --watch",
"prerelease": "npm run build",
"release": "release-it"
},
"devDependencies": {
"@commitlint/cli": "17.1.2",
"@commitlint/config-angular": "17.1.0",
"@nestjs/common": "9.1.2",
"@types/jest": "29.1.0",
"@types/node": "16.11.62",
"@typescript-eslint/eslint-plugin": "5.38.1",
"@typescript-eslint/parser": "5.38.1",
"class-transformer": "0.5.1",
"class-validator": "0.13.2",
"eslint": "8.24.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"husky": "8.0.1",
"jest": "29.1.1",
"lint-staged": "13.0.3",
"prettier": "2.7.1",
"reflect-metadata": "0.1.13",
"release-it": "15.4.2",
"rimraf": "3.0.2",
"ts-jest": "29.0.3",
"typescript": "4.8.4"
},
"peerDependencies": {
"@nestjs/common": "^7.0.8 || ^8.0.0 || ^9.0.0",
"class-transformer": "^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0",
"class-validator": "^0.11.1 || ^0.12.0 || ^0.13.0",
"reflect-metadata": "^0.1.12"
},
"peerDependenciesMeta": {
"class-validator": {
"optional": true
},
"class-transformer": {
"optional": true
}
},
"lint-staged": {
"*.ts": [
"prettier --write"
]
},
"husky": {
"hooks": {
"commit-msg": "commitlint -c .commitlintrc.json -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
},
"repository": {
"type": "git",
"url": "https://github.com/nestjs/mapped-types"
}
}

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE

View File

@@ -0,0 +1,16 @@
# Installation
> `npm install --save @types/validator`
# Summary
This package contains type definitions for validator.js (https://github.com/validatorjs/validator.js).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/validator.
### Additional Details
* Last updated: Sat, 22 Oct 2022 03:33:10 GMT
* Dependencies: none
* Global values: `validator`
# Credits
These definitions were written by [tgfjt](https://github.com/tgfjt), [Ilya Mochalov](https://github.com/chrootsu), [Ayman Nedjmeddine](https://github.com/IOAyman), [Louay Alakkad](https://github.com/louy), [Bonggyun Lee](https://github.com/deptno), [Naoto Yokoyama](https://github.com/builtinnya), [Philipp Katz](https://github.com/qqilihq), [Jace Warren](https://github.com/keatz55), [Munif Tanjim](https://github.com/MunifTanjim), [Vlad Poluch](https://github.com/vlapo), and [Piotr Błażejewicz](https://github.com/peterblazejewicz).

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.blacklist;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.contains;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.equals;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.escape;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isAfter;

View File

@@ -0,0 +1,3 @@
import validator from '../../';
export type AlphaLocale = validator.AlphaLocale;
export default validator.isAlpha;

View File

@@ -0,0 +1,3 @@
import validator from '../../';
export type AlphanumericLocale = validator.AlphanumericLocale;
export default validator.isAlphanumeric;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isAscii;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isBIC;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isBase32;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isBase58;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isBase64;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isBefore;

View File

@@ -0,0 +1,3 @@
import isBoolean, { Options } from '../../lib/isBoolean';
export default isBoolean;
export { Options };

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isBtcAddress;

View File

@@ -0,0 +1,3 @@
import validator from '../../';
export type IsByteLengthOptions = validator.IsByteLengthOptions;
export default validator.isByteLength;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isCreditCard;

View File

@@ -0,0 +1,3 @@
import validator from '../../';
export type IsCurrencyOptions = validator.IsCurrencyOptions;
export default validator.isCurrency;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isDataURI;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isDate;

View File

@@ -0,0 +1,4 @@
import validator from '../../';
export type IsDecimalOptions = validator.IsDecimalOptions;
export type DecimalLocale = validator.DecimalLocale;
export default validator.isDecimal;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isDivisibleBy;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isEAN;

View File

@@ -0,0 +1,3 @@
import isEmail, { IsEmailOptions } from '../../lib/isEmail';
export default isEmail;
export { IsEmailOptions };

View File

@@ -0,0 +1,3 @@
import validator from '../../';
export type IsEmptyOptions = validator.IsEmptyOptions;
export default validator.isEmpty;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isEthereumAddress;

View File

@@ -0,0 +1,3 @@
import isFQDN, { IsFQDNOptions } from '../../lib/isFQDN';
export default isFQDN;
export { IsFQDNOptions };

View File

@@ -0,0 +1,4 @@
import validator from '../../';
export type FloatLocale = validator.FloatLocale;
export type IsFloatOptions = validator.IsFloatOptions;
export default validator.isFloat;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isFullWidth;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isHSL;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isHalfWidth;

View File

@@ -0,0 +1,3 @@
import validator from '../../';
export type HashAlgorithm = validator.HashAlgorithm;
export default validator.isHash;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isHexColor;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isHexadecimal;

View File

@@ -0,0 +1,3 @@
import isIBAN, { locales } from '../../lib/isIBAN';
export default isIBAN;
export { locales };

View File

@@ -0,0 +1,3 @@
import validator from '../../';
export type IPVersion = validator.IPVersion;
export default validator.isIP;

View File

@@ -0,0 +1,3 @@
import validator from '../../';
export type IPVersion = validator.IPVersion;
export default validator.isIPRange;

View File

@@ -0,0 +1,3 @@
import validator from '../../';
export type ISBNVersion = validator.ISBNVersion;
export default validator.isISBN;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isISIN;

View File

@@ -0,0 +1,3 @@
import isISO31661Alpha2, { CountryCodes } from '../../lib/isISO31661Alpha2';
export default isISO31661Alpha2;
export { CountryCodes };

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isISO31661Alpha3;

View File

@@ -0,0 +1,3 @@
import isISO4217, { CurrencyCodes } from '../../lib/isISO4217';
export default isISO4217;
export { CurrencyCodes };

View File

@@ -0,0 +1,3 @@
import validator from '../../';
export type IsISO8601Options = validator.IsISO8601Options;
export default validator.isISO8601;

View File

@@ -0,0 +1,2 @@
import validator from '../../';
export default validator.isISRC;

View File

@@ -0,0 +1,3 @@
import validator from '../../';
export type IsISSNOptions = validator.IsISSNOptions;
export default validator.isISSN;

View File

@@ -0,0 +1,3 @@
import validator from '../../';
export type IdentityCardLocale = validator.IdentityCardLocale;
export default validator.isIdentityCard;

Some files were not shown because too many files have changed in this diff Show More