xogroup / felicity

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

Object().rename() is wrong #124

Closed WesTyler closed 7 years ago

WesTyler commented 7 years ago

Context

What are you trying to achieve or the steps to reproduce ?

Renamed keys on objects should be respected for example data generation. Felicity.example is currently renaming in the wrong direction.

What result did you expect ?

> Joi.object().keys({a: Joi.string()}).rename('b', 'a').validate({b: 'here'})
// { error: null, value: { a: 'here' } }
> Felicity.example(Joi.object().keys({a: Joi.string()}).rename('b', 'a'))
// { a: '2ezis0rcum90029hher85b3xr' }

What result did you observe ?

> Joi.object().keys({a: Joi.string()}).rename('b', 'a').validate({b: 'here'})
// { error: null, value: { a: 'here' } }
> Felicity.example(Joi.object().keys({a: Joi.string()}).rename('b', 'a'))
// { b: '2ezis0rcum90029hher85b3xr' }