ex_json_schema icon indicating copy to clipboard operation
ex_json_schema copied to clipboard

Introduces Nullable validator

Open linnal opened this issue 3 years ago • 0 comments

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:

  1. Allow Types to accept nil and let nullable to do the check if nullable is set => By default nil is accepted as a value, especially if nullable is not set
  2. Keep the current logic of not allowing nil as a valid value, but add somehow nullable: false by 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 :)

linnal avatar Nov 01 '22 10:11 linnal