Skip to content

admatic-tool/filter-params

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FilterParams.js

install

$ npm install filter-params

usage:

  const attrs = {
    user_id: "xxx",
    email: "[email protected]",
    name: null,
    isValid: false,
  }

  const filter = new FilterParams(attrs)

Require an attribute

  filter.req([ "name" ])
  // or in rest style
  filter.req("name")

  // raise Error `name is required`

Filtering attributes

exclude attrbutes

  filter.exclude([ "name" ]).commit()
  // or in rest style
  filter.exclude("name").commit()

  /* {
    user_id: "xxx",
    email: "[email protected]",
    isValid: false,
  } */

permit attributes

  filter.permit([ "email" ]).commit()
  // or in rest style
  filter.permit("email").commit()

  /* {
    email: "[email protected]",
  } */

About

Helper to filter params

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published