question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

question: How to create Conditional Custom Validation?

See original GitHub issue

Here 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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dennbagascommented, Sep 9, 2020

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 version

0reactions
github-actions[bot]commented, Dec 14, 2022

This 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found