Skip to content
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

rounding money values, better error Messages #7

Open
jacobitosuperstar opened this issue Nov 14, 2024 · 4 comments
Open

rounding money values, better error Messages #7

jacobitosuperstar opened this issue Nov 14, 2024 · 4 comments

Comments

@jacobitosuperstar
Copy link

Hello everyone, first of all, thanks for the package, for me has been great inspiration for my work and my learning of Go.

Wanted to ask you guys, if rounding down to 2 decimals, as almost all the monetary values are worked at best at the cents level, is going to be a part of the package eventually or if is something I could do a PR on.

Same with better error messages. As I was learning how to use this stuff and do my own program, I got thrown into the rabbit hole of better error messages which could be something I could also do a PR on.

Just wanted to see if that work would be valuable before doing a PR.

I have this proposals already implemented here, if you may want to take a look.

@alpeb
Copy link
Owner

alpeb commented Nov 20, 2024

Hi @jacobitosuperstar thanks for the interest. I'm currently not available to take a look, but this is just to say that it's on my radar for the next couple of weeks. Thanks!

@jacobitosuperstar
Copy link
Author

Hi @alpeb,

Totally understand, I don't think that I need to show you how rounding works, as is just using the round function in Go, but this is how the error cascade would look like, when an error is encountered.

image

Thanks for the response,
Have a great day.

@alpeb
Copy link
Owner

alpeb commented Nov 28, 2024

IIUC, you're introducing a ValidationError struct as a wrapper around all errors? I really don't see the benefit of the additional abstraction, over what we already have. About rounding, I think the library should be as precise as possible, and then consumers can format results as they wish.

@jacobitosuperstar
Copy link
Author

That's true, but the thing that I experienced was that, when I as in a long chain within the formulas, I found it hard to know the wrong value and the formula on which the wrong value was, so the idea of that struct is to record the value, the field, and the message of where you are in the chain. While using Pydantic and checking out their error messages and all of that, found it a neat feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants