Introduces Nullable validator
This is another "refactored" version of this PR
Here I tried to follow the current logic and add a Validator.
The current problem I encountered is that validators get executed only if the property is set.
By adding a Nullable property, we need to make sure that Types does not complain anymore about nil values. This goes against the current logic and current tests suit, which assumes that nil should not be allowed a valid value for the defined types.
So, there is a decision to be made here:
- Allow Types to accept
niland let nullable to do the check ifnullableis set => By default nil is accepted as a value, especially if nullable is not set - Keep the current logic of not allowing
nilas a valid value, but add somehownullable: falseby default
- If we go with step 1 there are lots of tests that need changing
Why do we want to allow Types to have nil value? Because validators are independent, and if nullable is set to true, we do not want Types to complain related to nil values.
Maybe there is another option I'm not considering, let's discuss further :)