Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/quantumsheep/class-validator-mongo-object-id
Add a decorator to validate MongoDB's ObjectId using class-validator
https://github.com/quantumsheep/class-validator-mongo-object-id
class-validator mongodb mongoose nestjs objectid validator
Last synced: 16 days ago
JSON representation
Add a decorator to validate MongoDB's ObjectId using class-validator
- Host: GitHub
- URL: https://github.com/quantumsheep/class-validator-mongo-object-id
- Owner: quantumsheep
- License: mit
- Created: 2020-12-16T15:36:36.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-11-09T09:42:17.000Z (about 1 year ago)
- Last Synced: 2024-09-20T11:36:28.829Z (about 2 months ago)
- Topics: class-validator, mongodb, mongoose, nestjs, objectid, validator
- Language: TypeScript
- Homepage:
- Size: 45.9 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![npm](https://img.shields.io/npm/v/class-validator-mongo-object-id)](https://www.npmjs.com/package/class-validator-mongo-object-id)
# ObjectId Class Validator
This package validates ObjectId in classes. It was originally made to be used in NestJS but works everywhere else.## How to install
```bash
npm install --save class-validator-mongo-object-id
```## How to use
Here is an example along with commonly used `IsString` from [`class-validator`](https://github.com/typestack/class-validator) package.```ts
import { IsString } from 'class-validator';
import { IsObjectId } from 'class-validator-mongo-object-id';class EditUserDTO {
@IsObjectId()
userId: string;@IsString()
username: string;
}
```