You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
maxLength ignored during delimited bean writing #96
I am using BeanIO to convert a bean (with a number of sub-records and so on)
into a pipe-separated value string. However, the inputs to this bean aren't
guaranteed to line up with the maximum lengths allowed at the other end, so
some validation needs to occur.
I have set the max length property in the @Field annotation, but it's being
completely ignored during the writing of the bean - if I set a value of "ABC"
on a field with a maxLength of 1, I get output like "...|ABC|...", which isn't
what I want. I would prefer that it is either trimmed, or, preferably, rejected
with an exception. If needed, I can attach some sample code to demonstrate the
issue.
Checking the code, Field simply doesn't perform any of this checking when
marshalling. I had a look at perhaps doing it in the same way as the
unmarshaller does, but I'm not sure if that's a good idea (would also require a
bunch of copy-paste coding).
Incidentally, I would also prefer it if during any bean writing, it threw an
exception if the value was longer than the length or maxLength of the field -
silently trimming it for Fixed-length records and ignoring it for delimited
records is (A) inconsistent, and (B) dangerous, at least in my mind. I can
raise a new issue about that, if you prefer.
Original issue reported on code.google.com by nzipsi@gmail.com on 16 Dec 2013 at 4:47
Activity