RequiredIf EDI Validation Attribute not working


Hello Community,

In my project, I just recently upgraded to  EdiFabric.Core.Full/EdiFabric.Framework.Full/EdiFabric.Plugins.Ack.X12.Full version in order to take advantage of the RequiredIf validation attribute, however, it doesn't fail validation in the following scenario:

Sample 835 File Segment:

Segment Attribute Setup: 

[DataElement("591", typeof(X12_ID_591_3))]
public override string PaymentMethodCode_04 { get; set; }

[RequiredIf(4, "ACH")]
[DataElement("812", typeof(X12_ID_812))]
public override string PaymentFormatCode_05 { get; set; }

As you can see PaymentMethodCode_04 has a value of "ACH" and PaymentFormatCode_05 is blank in the sample 835 File segment above. I would expect this to cause a validation error according to the [RequiredIf(4, "ACH")] attribute I have defined on the PaymentFormatCode_05 property, however, it does not. Any help here would be much appreciated.





  • Hi, this is exactly how the attribute should be working. Is this the only BPR segment in the template? sometimes, there are more than one segment with the same ID, and you need to apply that change to the exact one that refers to the segment data.

    Comment actions Permalink
  • Hi Don,

    Thanks for responding! It's one of two BPR segments across two separate transactions with the same ID. The RequiredIf attribute is applied as laid out above, but I'm not getting a validation error like I'd expect.

    Comment actions Permalink
  • Hi Bryan, could you please send us your modified template and a test file to reproduce the issue at our end? Please create a ticket in the support portal here.

    Comment actions Permalink
  • Update: the issue was that in the RequiredIf attribute all values must be enclosed in commas, like:

    [RequiredIf(4, ",ACH,")]
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post