xogroup / felicity

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

Throw error on non-object schema passed to .entityFor #92

Closed WesTyler closed 7 years ago

WesTyler commented 7 years ago

Description

Constructor functions must return objects, so provided schema should also respect the same restriction.

Related Issue

91

Motivation and Context

Prior to this patch when a non-object schema was passed to Felicity.entityFor, the constructor function would be returned without error. However, when a new instance was instantiated, it would return an empty object despite having the instance.schema returning the correct non-object Joi schema.

This patch enforces object-typed Joi schema as the basis for constructor functions to maintain the parity of restrictions between schema and returned value for the constructors.

Types of changes

Checklist: