Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pay-k/class-validator-extras
https://github.com/pay-k/class-validator-extras
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/pay-k/class-validator-extras
- Owner: pay-k
- License: mit
- Created: 2019-09-16T19:32:45.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-11T22:20:30.000Z (about 2 years ago)
- Last Synced: 2025-01-04T04:12:32.305Z (about 1 month ago)
- Language: TypeScript
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Class Validator Extras
## Install
```
npm install @payk/class-validator-extras
```## Usage
### ValidateWithCondition
The decorator needs to define a function that receives two values, an object of the current class and the value of the current property. It needs to return a boolean.
You can also pass the options object and override the message for your usage.
```ts
class MyClass {startDate: Date;
@ValidateWithCondition((obj: MyClass, val: Date) => val > obj.startDate, { message: 'ExpirationDate must be after the StartDate' })
expirationDate: Date;
}
```