Skip to content

Latest commit

 

History

History

schm-methods

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

schm-methods

NPM version

Adds methods to schm parsed objects.

Install

$ npm install --save schm-methods

Usage

const schema = require('schm')
const methods = require('schm-methods')

const userSchema = schema({
  name: String,
  preferredLanguages: [String],
}, methods({
  codeIn: (values, language) => values.preferredLanguages.includes(language),
}))

const user = userSchema.parse({
  name: 'Haz',
  preferredLanguages: ['JavaScript', 'Swift', 'C#'],
})

user.codeIn('JavaScript') // true
user.codeIn('Java') // false

API

Table of Contents

methods

Adds methods to schm parsed object.

Parameters

License

MIT © Diego Haz