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

Non-exception-based API #77

Open
milgner opened this issue Jul 10, 2023 · 0 comments
Open

Non-exception-based API #77

milgner opened this issue Jul 10, 2023 · 0 comments

Comments

@milgner
Copy link

milgner commented Jul 10, 2023

Is your feature request related to a problem? Please describe.

This library looks very interesting! But with exceptions generally being sophisticated GOTO statements, using them for validations feels very wrong. Especially since validation failure is not really an exception at all: it is expected to happen on a regular basis and part of the regular business process.

Describe the solution you'd like

I'd like an API that returns some kind of ValidationResult object which can be either "OK" or "Failed" and which contains all the information about the failure(s), including error messages and failed values.

Personally I really like the API of Kalidation which uses arrow.core.Validated (to be replaced with a regular Either in upcoming Arrow releases) - although in turn its many dependencies give it a much bigger footprint than Valiktor.

Describe alternatives you've considered

I was thinking about creating a wrapper method that catches the exception and encapsulates the information in a validation result object. Looking at #75 I'm not sure that it would be possible to get all the information from the exception, though.

Additional context

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

No branches or pull requests

1 participant