-
Notifications
You must be signed in to change notification settings - Fork 40
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
Validate without exceptions? #29
Comments
The consumer can still perform all of the validations on it's own, without having to call the
|
I'm new to ValueObjects so forgive me if this is a bad idea, but I wanted to avoid throwing exceptions during validation for a variety of reasons and instead have a collection of validation errors. So I added:
private readonly List<TValidationResult> _errors;
and later:
To the ValueOf base class. This allows the ValueOf consumer to decide whether Validate should throw exceptions, or TryValidate should just fail silently; or whether both should append one or more validation errors to a collection that can be displayed to a user or logged.
Is there a reason I'm unaware of as to why throwing exceptions seems to be the preferred validation mechanism?
The text was updated successfully, but these errors were encountered: