-
Notifications
You must be signed in to change notification settings - Fork 114
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
Custom error message for Assertion #1218
Comments
Alternatively, you can use object Name extends Subtype[String] {
override def assertion = assertCustom { str =>
if (str.trim.size >= 1) Right(()) else Left(AssertionError.Failure("This is an error"))
}
} Note that this is in Scala2. |
Thanks. I settled on this for now
|
When adding a new type e.g:
It would be nice to be able to set a custom error message that's a bit more user friendly if the assertion fails. Right now this assertion would give us
did not satisfy hasLength(greaterThanOrEqualTo(1))
, which isn't that user friendly if returned to an actual user. It's possible to remap the error if we use make, e.gName.make("my name")
but that's a bit to easy to forget.Would it make sense to be able to set a custom error message on an
Assertion
?The text was updated successfully, but these errors were encountered: