v5.0.0-rc.2
Pre-release
Pre-release
·
58 commits
to develop
since this release
What's Changed
Added
- Added a static
tryFrom()method to theIntegerId,StringIdandUuididentifier classes. This method returnsnullif the value provided cannot be cast to the identifier type. - The static
from()method on all the identifier classes now acceptsnullbut throws in this scenario. This allows it to be used where the value you are casting is possibly null. - New methods on the
ListOfErrorsinterface:find()to find the first matching error.sole()to get the first error, but only if exactly one error exists.any()to determine if any of the errors match.every()to determine if every error matches.filter()to get a new list containing only matching errors.
- The
FailedResultExceptionnow has a message when the result has an error code but no error message. - The
FakeExceptionReporternow hasnone()andexpect()helper methods, to prevent exceptions from being swallowed in tests. - BREAKING: Changes to the result interface to support the following features. Although technically breaking, this will not affect the majority of implementations are the concrete result class provided by this package has been updated.
- Can now pass a default value to the
Result::error()method. This default value can either be a string or a closure that receives the error code. (Errors always have codes if they do not have messages.) - Added
Result::code()method to get the first error code in the result's errors.
- Can now pass a default value to the
Deprecated
- The
ListOfErrors::contains()method is deprecated and will be removed in 6.0. Use the newany()method instead. - Calling the
ListOfErrors::first()method with arguments is deprecated and will be removed in 6.0. Use the newfind()method instead.
Full Changelog: v5.0.0-rc.1...v5.0.0-rc.2