npm.io
1.0.3 • Published 3 years ago

vanilla-object-parser

Licence
ISC
Version
1.0.3
Deps
4
Size
16 kB
Vulns
0
Weekly
0

vanilla-object-parser

Simple vanilla object parser

Sample schema

const userSchema = {
  user: {
    type: 'object',
    properties: {
      name: { type: 'string' },
      lastName: { type: 'string' },
    },
  },
};

Sample input

const obj = {
  user: {
    name: 'Jhon',
    lastName: 'Wick',
    password: '123456',
  },
};
Sample usage
const { getObjectBySchema } = require('vanilla-object-parser');
const output = getObjectBySchema(obj, userSchema);

console.log(output);

Keywords