question: How to create Conditional Custom Validation?
See original GitHub issueHere is my DTO:
export class ApplyCashbackDto {
@IsNotEmpty()
promoCode: string
// Conditional Validation
extras: string
}
I was trying to conditionally validate the extras property based on promoCode property, but i have to check first to the DB if the promoCode need some extras data because not all the promoCode must include the extras property
How to achieve this custom coditional validation?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Integrating nested conditional logic in custom validation for ...
The whole trick is by using, as you said, nested logic within the Custom Validation option: Just click on any of my questions...
Read more >Conditional Validation -- Help Manual - Survey2Connect
Conditional Validation · 1. Go to the question to which you want to add the logic to. · 2. Click on the logic...
Read more >Add Custom Conditional Validation rules to the same attribute
It honestly makes no sense why you would want to create a custom validator for this. Laravel comes with file rule to check...
Read more >How do I add conditional validation? - Drupal Answers
You can use the States API to make a field visually required, visible/hidden and so on. One simple example from https://randyfay.com/states
Read more >Validation Rules - FormAssembly Resource Center
Require a Custom Format · Select your question and click the Options button to open the editing sidebar. · Select Validation Rules from...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @NickKelly1
Yes, i can create custom async validator, but that wasn’t an optional validator. Its like regular validator that validate the value is right or not.
What i want is a custom optional async validation. Something like
@ValidateIf()but async versionThis issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.