Skip to content

Latest commit

 

History

History

schm-translate

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

schm-translate

NPM version

Translates values keys to schema keys.

Install

$ npm install --save schm-translate

Usage

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',
}

API

Table of Contents

translate

Translates values keys to schema keys.

Parameters

License

MIT © Diego Haz