Closed JasonLounsbery closed 8 years ago
I'm afraid I cannot help you because your question doesn't define what the problem is.
The issue is that the properties are being flagged as required regardless of what IsRequired is returning. I thought that the RequiredIf attribute would reflect what ever the function IsRequired returned. If IsRequred returns True and the Address field is blank, the error message shows up. if IsRequred returns False, and the Address field is blank, the error message shows up.
The issue is that the properties are being flagged as required regardless of what IsRequired is returning. I thought that the RequiredIf attribute would reflect what ever the function IsRequired returned. If IsRequred returns True and the Address2 field is blank, the error message shows up. if IsRequred returns False, and the Address2 field is blank, the error message shows up.
Here is my code. For testing I have isRequired returning false.
…Model
[DataMember] [Description("Address Line 2")] [RequiredIf("isRequired(ADDRESS2,'STREET2') ", ErrorMessage = "Address is Required")] public string ADDRESS2 { get; set; }
public bool isRequired(string value,string FieldName) { return false; }
Jason Lounsbery GEMMS 10201 N. Illinois Street Suite 140 Indianapolis, IN 46290 www.gemmsnet.com Ph: 317-819-5060 Ph: 800-773-3111 Fax: 317-819-5071
From: Jarosław Waliszko [mailto:notifications@github.com] Sent: Saturday, June 25, 2016 3:48 PM To: jwaliszko/ExpressiveAnnotations ExpressiveAnnotations@noreply.github.com Cc: Jason Lounsbery jlounsbery@gemmsnet.com; Author author@noreply.github.com Subject: Re: [jwaliszko/ExpressiveAnnotations] custom property with RequiredIf (#126)
I'm afraid I cannot help you because your question doesn't define what the problem is.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jwaliszko/ExpressiveAnnotations/issues/126#issuecomment-228567269, or mute the threadhttps://github.com/notifications/unsubscribe/ATDQc7rxxCVAfDDSTaoudUcdCk-08Vf3ks5qPYXYgaJpZM4I3ahn.
You should probably take a look at the documentation related to defining your own methods - if you are using client-side validation you need to define respective method at client-side as well. I assume you have an error related to undefined reference - check your web console output.
Also, I advise you to use GitHub directly instead of emails when posting here, because you have the opportunity to format your messages using markdown.
I have a property that determines if a field is required. It always says it is required
[DataMember] [Description("Address Line 2")] [RequiredIf("isRequired(ADDRESS2,'STREET2') ", ErrorMessage = "Address is Required")] public string ADDRESS2 { get; set; }
public bool isRequired(string value,string FieldName) { return false;
I removed the code for IsRequired so it always returns false
ADDRESS and ADDRESS2 are always required. Can something like this be done?