xogroup / felicity

Javascript object constructors and sample data based on Joi schema.
Other
111 stars 9 forks source link

Refactor /lib/helpers to leverage ES6 class syntax #112

Closed WesTyler closed 7 years ago

WesTyler commented 7 years ago

There is a ton of duplicate logic and checking in the example data generation code base at /lib/helpers. This also creates complex edge cases (like #111 ).

The example data generation should leverage classes so that base Joi rules like defaults, valids, examples, etc can be abstracted into the base Example class. Each "type" can then handle type-specific rules more cleanly, and "meta" types like alternatives and object keys do not have to re-create raw schema and parse the rules/defaults/flags all over again.