# vtypes-immutable

> Additional constraints for validate.js

Latest version **1.0.0** (published 2017-08-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install vtypes-immutable
pnpm add vtypes-immutable
yarn add vtypes-immutable
bun add vtypes-immutable
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-08-13 |
| First published | 2017-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Gerald Yeo |
| Maintainers | geraldyeo |
| Keywords | vtypes-modularized, vtypes, validate.js, validation, immutable |

## Links

- npm: https://www.npmjs.com/package/vtypes-immutable
- Repository: https://github.com/yeojz/vtypes/tree/master/packages/vtypes-immutable
- npm.io page: https://npm.io/package/vtypes-immutable

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-08-13

## README

# vtypes-immutable

> "immutable" validator for validate.js

[![npm package][npm-badge]][npm-link]
[![vtypes][vtypes-badge]][repository]

- [About](#about)
- [Installation](#installation)
- [Usage](#usage)
- [Available Options](#available-options)
- [License](#license)

## About

The `immutable` validator attempts to ensure that the field is a valid immutable value.
The API for checking immutability is referenced off [immutable.js](https://github.com/facebook/immutable-js).

If no parser is provided, then best effort guess if a value is immutable
based on availability of conversion functions like `toJS`, `toJSON`, `toArray`, `toObject`;

## Installation

```sh
$ npm install vtypes-immutable
```

```js
const validate = require('validate.js');
const vImmutable = require('vtypes-immutable');

// you can then proceed to register the required validators.
validate.validators.immutable = vImmutable;
```

## Usage

```js
const Immutable = require('immutable');

validate({}, {attr: {immutable: true}});
// => undefined

validate({attr: 'foo'}, {attr: {immutable: true}});
// => {attr: ["Attr is not an immutable value"]}
```

```js

// note: both "type" and "library" must be preset.
const constraints = {
  attr: {
    immutable: {
      library: Immutable,
      type: 'List'
    }
  }
}

validate({attr: 'foo'}, constraints);
// => {attr: ["Attr is not an immutable List"]}
```

For more examples, check out the test files in this package's [source][src] folder.

## Available Options

| name    | type   | default                       | description                                  |
| ------- | ------ | ----------------------------- | -------------------------------------------- |
| library | func   | `undefined`                   | The immutable library                        |
| message | string | `is not an immutable %{type}` | Error message                                |
| type    | string | `undefined`                   | A type that is accepted by immutable library |

## License

`vtypes-immutable` is [MIT licensed][license]

[npm-badge]: https://img.shields.io/npm/v/vtypes-immutable.svg?style=flat-square
[npm-link]: https://www.npmjs.com/package/vtypes-immutable
[repository]: https://github.com/yeojz/vtypes
[vtypes-badge]: https://img.shields.io/badge/vtypes-repo-blue.svg?style=flat-square
[license]: https://github.com/yeojz/vtypes/blob/master/LICENSE
[src]: https://github.com/yeojz/vtypes/tree/master/packages/vtypes-immutable/src

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