# loopback-ds-sanitizer-mixin

> A mixin to automatically sanitizer attributes of loopback Models

Latest version **0.0.3** (published 2016-06-23) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install loopback-ds-sanitizer-mixin
pnpm add loopback-ds-sanitizer-mixin
yarn add loopback-ds-sanitizer-mixin
bun add loopback-ds-sanitizer-mixin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2016-06-23 |
| First published | 2016-05-09 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4.x |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Foko Inc. |
| Maintainers | foko |
| Keywords | loopback, strongloop, mxin, sanitize, sanitizing, unicode |

## Links

- npm: https://www.npmjs.com/package/loopback-ds-sanitizer-mixin
- Repository: https://github.com/FoKo/loopback-ds-sanitizer-mixin
- Homepage: https://github.com/FoKo/loopback-ds-sanitizer-mixin#readme
- Issues: https://github.com/FoKo/loopback-ds-sanitizer-mixin/issues
- npm.io page: https://npm.io/package/loopback-ds-sanitizer-mixin

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) 2.x

## Recent versions

- 0.0.3 (latest) — 2016-06-23
- 0.0.2 — 2016-05-19
- 0.0.1 — 2016-05-09

## README

This module is designed for the [Strongloop Loopback](https://github.com/strongloop/loopback) framework.

[![license](https://img.shields.io/badge/license-Apache_2.0-blue.svg)]()
[![Build Status](https://travis-ci.org/FoKo/loopback-ds-sanitizer-mixin.svg?branch=master)](https://travis-ci.org/FoKo/loopback-ds-sanitizer-mixin)

# loopback-ds-sanitizer-mixin

Sanitize user input when persisting data.

## Options

To use with your Models add the `mixins` attribute to the definition object of your model config.

```json
  {
    "name": "Widget",
    "properties": {
      "name": {
        "type": "string"
      }
    },
    "mixins": {
      "sanitizer" : {
        "field1": INPUT_CLASS,
        "field2": INPUT_CLASS
      },
    }
  }
```

Where INPUT_CLASS must be one of:

 - oneLineString: Removes new lines, Remove control characters, trim spaces
 - multiLineString: Keeps new lines, Remove control characters, trim spaces

## INSTALL

```bash
  npm install --save loopback-ds-sanitizer-mixin
```

## MIXINSOURCES
With [loopback-boot@v2.8.0](https://github.com/strongloop/loopback-boot/)  [mixinSources](https://github.com/strongloop/loopback-boot/pull/131) have been implemented in a way which allows for loading this mixin without changes to the `server.js` file previously required.

Add the `mixins` property to your `server/model-config.json` like the following:

```json
{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "../node_modules/loopback-ds-sanitizer-mixin",
      "../common/mixins"
    ]
  }
}
```

## TESTING

Run the tests in `test/test.js`

```bash
  npm test
```

Run with debugging output on:

```bash
  DEBUG='loopback-ds-sanitizer-mixin' npm test
```

# VERSIONS

 - [0.0.1](https://github.com/FoKo/loopback-ds-sanitizer-mixin/releases/tag/0.0.1)

# LICENSE
[Apache-2.0](LICENSE)

---
_Source: https://npm.io/package/loopback-ds-sanitizer-mixin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
