No description
Find a file
2025-11-04 15:23:00 +01:00
src fix: Prop 2023-10-10 15:25:28 +02:00
.eslintrc.json 🎉 Initial commit 2023-01-08 14:05:50 +01:00
.gitignore 🎉 Initial commit 2023-01-08 14:05:50 +01:00
.gitlab-ci.yml Only run on release 2023-01-09 12:35:36 +01:00
jest.config.cjs 🎉 Initial commit 2023-01-08 14:05:50 +01:00
nest-cli.json Update 2 2023-01-09 10:14:33 +01:00
package.json chore: Remove old urls 2025-11-04 15:23:00 +01:00
pnpm-lock.yaml chore: Update dependencies 2025-11-04 13:48:14 +01:00
README.md How to publish 2023-04-21 11:38:21 +02:00
tsconfig.build.json Update 2 2023-01-09 10:14:33 +01:00
tsconfig.json Update 2 2023-01-09 10:14:33 +01:00

Installation

You can use the following .npmrc to configure installing this package:

@devdroplets:registry=http://git.devdroplets.com/api/v4/projects/222/packages/npm/
//git.devdroplets.com/api/v4/projects/222/packages/npm/:_auth=Z2l0bGFiK2RlcGxveS10b2tlbi04Njp4b3NHcVNCcDJyOWotc3cxeW0zVg==
always-auth=true

Publishing a new version

After you've modified code, you can easily publish a new version with the following command:

yarn new

This will ask you what the new version is and automatically commit the correct message for gitlab ci to build.

Defining typed contexts

You can define typescript contexts easily by overwriting the declared module namespace in a decleration file.

First create a types/id-validation.d.ts file (name and place does not matter).

/* ./types/id-validation.d.ts */
import "@devdroplets/nestjs-id-validation";
import { PrismaService } from "prisma/prisma.service";

declare module "@devdroplets/nestjs-id-validation" {
  export interface ValidationContext {
    prisma: PrismaService;
  }

  export interface ValidationPayload {
    /** Additional types in all validations */
  }
  export interface ValidationPayloadConstraint {
    /** Additional types in constraint validations */
  }
  export interface ValidationPayloadRequest {
    /** Additional types request validations */
  }
}

Next you add this in your tsconfig.json file as a typeRoots folder. For example:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es2018",

    "outDir": "./dist",
    "baseUrl": "./",
    "typeRoots": ["./types"]
  }
}

No everywhere you use defineIdValidation(ctx => { ... }) your ctx argument is typed correctly.