jwaliszko / ExpressiveAnnotations

Annotation-based conditional validation library.
MIT License
351 stars 123 forks source link

RequiredIf on Guid fields - demands that field be changed to Guid? #127

Closed ssteiner closed 8 years ago

ssteiner commented 8 years ago

Hi

I'm using Expressive Annotations to selectively validate some of my models. One of them has these properties and requiredif dependency

    [RequiredIf("ClusterId != 0")]
    public Guid DefaultLocaleId { get; set; }

  public int ClusterId { get; set; }

In case ClusterId == 0, DefaultLocaleId would be Guid.Empty. And yet we suddenly get a validation error that DefaultLocaleId has to be nullable for the RequiredIf attribute to work.

And I wonder why that is. ClusterId being null, there should be no validation of DefaultLocaleId in my opinion.

jwaliszko commented 8 years ago

https://github.com/jwaliszko/ExpressiveAnnotations/tree/bcdfaef599ad9644344170031042710b765af984#requiredif-attribute-is-not-working-what-is-wrong