Translates values keys to schema keys.
$ npm install --save schm-translate
const schema = require('schm')
const translate = require('schm-translate')
const userSchema = schema({
name: String,
email: String,
}, translate({
name: 'username',
email: 'emails.0',
}))
const user = userSchema.parse({
username: 'Haz',
emails: [
'hazdiego@gmail.com',
'diegohaz@live.com',
],
})
Output:
{
name: 'Haz',
email: 'hazdiego@gmail.com',
}
Translates values keys to schema keys.
params
Object
MIT © Diego Haz