2.0.0 • Published 6 years ago

filter-params v2.0.0

Weekly downloads
96
License
ISC
Repository
-
Last release
6 years ago

FilterParams.js

install

$ npm install filter-params

usage:

  const attrs = {
    user_id: "xxx",
    email: "xxx@email.com",
    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: "xxx@email.com",
    isValid: false,
  } */

permit attributes

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

  /* {
    email: "xxx@email.com",
  } */
2.0.0

6 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago