Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to validate multiple condition in AssertThat validation #191

Open
makwana8055 opened this issue Aug 23, 2018 · 2 comments
Open

unable to validate multiple condition in AssertThat validation #191

makwana8055 opened this issue Aug 23, 2018 · 2 comments

Comments

@makwana8055
Copy link

makwana8055 commented Aug 23, 2018

    [Display(ResourceType = (typeof(DisplayNamesForWeb)), Name = "SuggestedRequest")]
    public decimal? Amount1 { get; set; }


    [Display(ResourceType = (typeof(DisplayNamesForWeb)), Name = "OriginalRequest")]
    [AssertThat(@"Amount1 != null && Amount2 != null  && Amount2 <= Amount1", ErrorMessageResourceType = typeof(ErrorMessagesForWeb), ErrorMessageResourceName = "Amount2 must be less than or equal to Amount1")]
    public decimal? Amount2 { get; set; }
  • If Amount1 and Amount2 has value then i want to check that amount2 should not be greater than amount1.
@karim-ting
Copy link

why not use separate assert annotations and give them different priority values as required?

@tempel3
Copy link

tempel3 commented Jul 2, 2020

"Amount1 == null || Amount2 == null || Amount2 <= Amount1" that should do it. It Amount1 hat no value -> true, if Amount2 has not value -> true and it Amount2 <= Amount1 -> true.

That way it will only check if Amount1 and Amount2 are set.

Is it what you need?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants