open-index/open-npm huggingface dataset:
npm package: @stackkit/gate
Description: > A simple gate class that can help with protecting and checking user abilities.
Author: larsvankleef
Latest version: 0.1.1

# Gate

> A simple gate class that can help with protecting and checking user abilities.

**This package is made to run in Nodejs because checking the gate access should be done in the backend but it can be used on the client side. For example to show or hide ui elements or protect client side routes**

### Define the gate rules
```js
import { Gate } from 'gate'

const user = { id: 1, role: 'admin' }

export function useGate({ user }) {
  const gate = new Gate({ user })

  gate.before(({ user }) => {
    return user.role === 'god'
  })

  gate.define('edit-users', ({ user }) => {
    return user.role === 'admin'
  })

  gate.define('edit-post', ({ user, post }) => {
    return post.user_id === user.id
  })

  return gate
}
```

### Use the gate rules
```js
import { useGate } from 'domain/gate'

const gate = useGate({ user })

gate.allows('edit-users')

const post = db.get('post')
gate.check('edit-post', { post })
```
npm package: @stackkit/validate
Description: > A simple validation util for react or vue. It works in nodejs to.
Author: larsvankleef
Latest version: 0.0.2

# Validate

> A simple validation util for react or vue. It works in nodejs to.

```js example
const { validate, email, length, required } = require('validate')

const rules = {
  fields: {
    email: {
      validator: value => {
        return length(value, { max: 75 }) && email(value)
      },
      message: ({ value }) => {
        return `${value} is not valid email address or the length is to high.`
      },
    },
    password: {
      validator: value => {
        return length(value, { min: 4, max: 18 })
      },
      message: ({ value, field }) => {
        return `The length of your password is tho short it must be between 4 and 18 charters long.`
      },
    },
    subscription: {
      validator: value => {
        return required(value)
      },
      message: `Please choose a subscription type`,
    },
  },
}

const { valid } = validate(fields, {
  rules,
})
```

## Good the now.

No sanitizing has been done on the return value in the message function. It is your job
to use a library to achieve this.

[dompurify](https://www.npmjs.com/package/dompurify)

### Nodejs

While working on this. I found this package [express-validator](https://github.com/express-validator/express-validator) it looks like a good option for validation inside nodejs express projects.