Model.$schema uses strings to name types. Let's make them Joi validators instead. Joi has a robust DSL for expressing type contracts that is available at run-time. We could put a hook on Model to test itself at instantiation and throw errors if there are mismatches (say) between an attribute's type and its default type. Plus, this makes it easier to build object validators (for extended fields).
Model.$schema uses strings to name types. Let's make them Joi validators instead. Joi has a robust DSL for expressing type contracts that is available at run-time. We could put a hook on Model to test itself at instantiation and throw errors if there are mismatches (say) between an attribute's type and its default type. Plus, this makes it easier to build object validators (for extended fields).