In unions of modddels, the validate methods also benefit from the shared properties feature and the case-modddels pattern matching.
Continuing with our Weather
example , here is an example of an implementation of the validateHabitable
method.
In this implementation, the 'habitable' validation will fail under the following conditions :
No matter the weather kind (Sunny
or Rainy
) : If the temperature
is more than 60 or less than -10, the validation fails
For the Rainy
weather : If the rainIntensity
is more than 2.5, the validation fails.