Adzz / data_schema

Declarative schemas for data transformations.
Apache License 2.0
86 stars 9 forks source link

Should has_many and list_of consider [] as nil if the field is not optional? #12

Closed Adzz closed 2 years ago

Adzz commented 2 years ago

Jury is still out. There is a good case for saying "yes", but for now we have gone with two new options:

empty_values default

These combine to allow someone to choose any value as empty - so they can apply [] to all list_of's or has_many.

This has the tradeoff of potentially being verbose (though you can help with macros). But it enables more flexibility to have empty values like :nan or :undefined or whatever the hell you want.