Boleto Validator - Support "convenio" and return which partial is wrong
This issue propose 2 features:
-
Add support for "convenio" in "boleto" validator, since it related formatter (
format-boleto) supports "convenio" -
Returns which partial is wrong in
is-valid-boleto. To avoid break the current contract, we could just add a second parameter, that will be a flag to turn on this feature.
I could work on both, just checking if are valid features
cc/ @hyanmandian
Hello @renatoagds, we are working in a fork project to refactoring the entire project and we plan to create 2 separated functions for that: format-bank-slip and format-covenant (I really don't know if these are the best names for that functions). If you need to format both cases, you can just compose these functions (or maybe we can create another function for that).
About is-valid-boleto, I think that we can fix this issue together with the refactoring.
Today I will create a branch with this fork and you could work with us :D
Thanks for the ideas and sorry for the delay.
Hey @renatoagds can you check next branch and confirm if we fixed your issue?
@hyanmandian for sure! will test today and let you know.
@hyanmandian Confirming that's not the expected.
-
The
nextbranch doesn't include support forconvenioinformatandisValid(this is actually a regression, sinceformatinmastersupportsconvenio). -
The current
isValidforboletodoesn't return which block is wrong, it only returns false/true.
Codesandbox that I used: https://codesandbox.io/s/brazilian-utils-rc-4qrj4
Can I help with the requested features in next?
Yes, I can help! What you think to add a second param to "config" the expected return? Something like:
isValidBoleto("1541541587487") // false
isValidBoleto("1541541587487", { block: true }) // [false, false, false, false, false, false]
I think that is better because we don't break our current API and it's work for all packages we have.
About convenio I think we need to create another package to do that and another package to format and validate boleto and convenio together, something like isValidBoletoCovenant or isValidBoletoConvenio and don't know a good name for convenio :(
What you think to add a second param to "config" the expected return?
That's exactly what I was thinking about. We could call this new param options maybe.
About convenio I think we need to create another package to do that
Why do you think this is necessary? That's some case that wouldn't use convenio? I think we could split the internal logic between convenio and conventional boleto, but in the final package, it should be exposed just one function, that detects if starts with 8 and switch between handlers.
I think is better to have 3 packages: boleto, convenio and boletoOrConvenio (we need to think in better names, ok? HahahHAh). In that way, we cover all use cases, what you think?
In that way, we cover all use cases, what you think?
Sounds good! 🚀
Hey @renatoagds we migrated our project to V2, it now have a simple structure, would you like to contribute?
@hyanmandian it's been a while since I left the company that I was working with these scenarios, I could try to contribute, but will need to remember a few things