mekanika / skematic

Data model & rule engine for JS objects
9 stars 0 forks source link

Handle null values #12

Closed cayuu closed 8 years ago

cayuu commented 9 years ago

Providing a mechanism to treat null values as "special" is important.

  1. [ ] NOT DOING .createFrom( scm ) (ie a format method) generates fields with undefined values where no "default" or "generate" is set - these undefined fields are removed entirely when serialised to JSON. Being able to specify an emptyValue would be handy to ensure empty fields persist post-serialisation
  2. [x] Conversely, when receiving de-serialised data in validate() it would be useful to treat null as being "ok".
cayuu commented 8 years ago

Recent commit f93d464a enabled an allowNull model descriptor that disables validation if user provides null as the value to validate.

cayuu commented 8 years ago

The emptyValue issue is simply not required at this point as the use-case (JSON stripping undefined) fields seems fine. Closing.