https://github.com/pay-k/class-validator-extras
https://github.com/pay-k/class-validator-extras
Last synced: 2 months 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 (over 2 years ago)
- Last Synced: 2025-03-17T09:25:15.889Z (3 months ago)
- Language: TypeScript
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- 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;
}
```