pluck
pluck copied to clipboard
Add Filters pipeline to config object
This PR adds a filter pipeline that can modify the results of a pluck as they are being extracted.
Moved the existing Sanitize and TrimSpace functions to be Filter types.
In my current use case i needed to implement a custom Sanitize method and after looking at the implementation thought this might be a useful way to handle that.
I tried to make the PR backwards compatible so that if a user doesn't explicitly set the Filters the Library defaults to the same filters as before (optional Sanitize, TrimSpace)
Also updated the tests to work with the addtions.
Open to suggestions
It could be used to modify and verify output, so in my case if the data is invalid i put it inside an error message that i can scrub afterwards. I thought about implementing an additional Verify function call that could return an error, but couldn't decide if that was the right way to handle it.
Thanks for the useful library!!
Sam