Validations
Throwing and catching exceptions is very expensive, so Typely
implements validations using the ValidationError
class. To avoid additional memory allocation, if all validations succeed, the object returned by the Validate
method will be null.
Note that you should use the TryFrom
method to perform validation without throwing an exception whenever possible otherwise From
.
Method
Mean
Error
StdDev
Gen0
Allocated
ReturnException
5,407.274 ns
28.0004 ns
26.1916 ns
0.0763
240 B
ReturnValidationError
9.879 ns
0.1042 ns
0.0924 ns
0.0153
48 B
Async validations
The validation state of a value object should not depend on external state or services. Therefore, asynchronous calls are not supported.
Last updated