-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add HeaderDecoder with custom header name matching #316
base: master
Are you sure you want to change the base?
Conversation
Right, this is really something I should put in the contribution guidelines. There's no issue that I can see with your PR, aside from a purely cosmetic one: the code is not formatted according to the project's guidelines. You just need to run the |
core/shared/src/main/boilerplate/kantan/csv/GeneratedHeaderDecoders.scala.template
Outdated
Show resolved
Hide resolved
Also: given that your use case is likely quite a common one, I wouldn't be against pre-defined helpers. We have one for case-sensitive headers, why not: [#
def caseInsensitiveDecoder[[#A1: CellDecoder#], R]([#f1: String#])(f: ([#A1#]) => R): HeaderDecoder[R] =
decoderWith([#f1#])(_.equalsIgnoreCase(_))(f)#
] |
@nrinaudo comments addressed |
I, err... were they? I'm not as used to the Github UI as I should be, but checking out the latest version of the branch locally still has |
Ah ok, I switched computers because scalafmt on my windows was going crazy, so I must have lost that change. Will fix |
Ok I think they should be fixed now 🤞 |
Closes #315
Adds a new set of
decoderWith
operators to theHeaderDecoder
andHeaderCodec
companion objects. The old methoddecoder
method now delegates todecoderWith
but uses the default equality check for strings.This allows users to override how the strings are compared when trying to determine the order of the headers in the mapping, e.g. when comparing the strings in a case insensitive manner.