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 9.8.7.5 in order to take advantage of the RequiredIf validation attribute, however, it doesn't fail validation in the following scenario:
Sample 835 File Segment:
BPR*C*601.00*C*ACH**01*124002890*DA*1111222233335544*******20200801~
Segment Attribute Setup:
[DataMember]
[Required]
[DataElement("591", typeof(X12_ID_591_3))]
[Pos(4)]
public override string PaymentMethodCode_04 { get; set; }
[DataMember]
[RequiredIf(4, "ACH")]
[DataElement("812", typeof(X12_ID_812))]
[Pos(5)]
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.
Thanks!
Comments
4 comments
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.
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.
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.
Update: the issue was that in the RequiredIf attribute all values must be enclosed in commas, like:
Please sign in to leave a comment.