javascript icon indicating copy to clipboard operation
javascript copied to clipboard

Boleto Validator - Support "convenio" and return which partial is wrong

Open renatoagds opened this issue 7 years ago • 12 comments

This issue propose 2 features:

  1. Add support for "convenio" in "boleto" validator, since it related formatter (format-boleto) supports "convenio"

  2. 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

renatoagds avatar Oct 25 '19 13:10 renatoagds

cc/ @hyanmandian

renatoagds avatar Oct 25 '19 13:10 renatoagds

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.

hyanmandian avatar Oct 29 '19 12:10 hyanmandian

Hey @renatoagds can you check next branch and confirm if we fixed your issue?

hyanmandian avatar Jan 13 '20 17:01 hyanmandian

@hyanmandian for sure! will test today and let you know.

renatoagds avatar Jan 13 '20 18:01 renatoagds

@hyanmandian Confirming that's not the expected.

  1. The next branch doesn't include support for convenio in format and isValid (this is actually a regression, since format in master supports convenio).

  2. The current isValid for boleto doesn'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?

renatoagds avatar Jan 14 '20 02:01 renatoagds

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.

hyanmandian avatar Jan 14 '20 12:01 hyanmandian

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 :(

hyanmandian avatar Jan 14 '20 12:01 hyanmandian

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.

renatoagds avatar Jan 14 '20 21:01 renatoagds

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?

hyanmandian avatar Jan 15 '20 12:01 hyanmandian

In that way, we cover all use cases, what you think?

Sounds good! 🚀

renatoagds avatar Jan 18 '20 01:01 renatoagds

Hey @renatoagds we migrated our project to V2, it now have a simple structure, would you like to contribute?

hyanmandian avatar Jan 21 '26 18:01 hyanmandian

@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

renatoagds avatar Jan 29 '26 14:01 renatoagds