EDI.Net icon indicating copy to clipboard operation
EDI.Net copied to clipboard

EDIValue(X(60)) is not limiting the string max length when serializing

Open GerardSilvente opened this issue 3 years ago • 1 comments

Hi,

I was serializing a file and I realized that EDIValue(X(60)) is not limiting the string max length when serializing despite the fact that I indicated 60 in the attribute.

[EdiValue("X(60)", Path = "POD/2", Description = "POD03 - Proof of delivery name / Received by")]
public string ProofOfDeliveryName { get; set; } 

Is there any reason why Edivalue attribute doesn’t validate string max length?

GerardSilvente avatar Jul 27 '21 12:07 GerardSilvente

Hi @GerardSilvente and thanks for your interest in the library.

In first glance I don't see why this is not implemented. Also I think in case it is introduced in the serializer then this could be turned off conditionally with a setting so it does not break any existing implementations.

It is not on my plans at the moment to introduce an enhancement but if you feel like making a contribution feel free to make a pull request. In order to do this one would have to work with EdiTextWriter and make use of the Picture parameter inside the method WriteEscapedString. https://github.com/indice-co/EDI.Net/blob/2b2d86e345a11106b7674384fb9b283f33ce3a3c/src/indice.Edi/EdiTextWriter.cs#L194

C.

cleftheris avatar Jul 27 '21 15:07 cleftheris