# jsdoc-to-condition

> Creates validation code from jsdoc comments

Latest version **0.3.0** (published 2017-09-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install jsdoc-to-condition
pnpm add jsdoc-to-condition
yarn add jsdoc-to-condition
bun add jsdoc-to-condition
```

## 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.3.0 |
| Published | 2017-09-11 |
| First published | 2017-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | jakwuh |
| Maintainers | jakwuh |

## Links

- npm: https://www.npmjs.com/package/jsdoc-to-condition
- Repository: https://github.com/jakwuh/jsdoc-to-condition
- Homepage: https://github.com/jakwuh/jsdoc-to-condition#readme
- Issues: https://github.com/jakwuh/jsdoc-to-condition/issues
- npm.io page: https://npm.io/package/jsdoc-to-condition

## Dependencies (1)

- [doctrine](https://npm.io/package/doctrine.md) ^2.0.0

## Recent versions

- 0.3.0 (latest) — 2017-09-11
- 0.2.1 — 2017-09-11
- 0.2.0 — 2017-09-11
- 0.1.1 — 2017-09-07
- 0.1.0 — 2017-09-07

## README

# jsdoc-to-condition [![Build Status][1]][2]
                     
 [1]: https://travis-ci.org/jakwuh/jsdoc-to-condition.svg?branch=master
 [2]: https://travis-ci.org/jakwuh/jsdoc-to-condition

> Creates validation code from jsdoc comments

### Example

```js
/**
 * @param {[string, number?]} a
 * @param {Object.<string, number>} b
 * @param {string|number} c
 */

// generates the following:

((Array.isArray(a) && (typeof a[0] === 'string') && ((a[1] == null) || (typeof a[1] === 'number')))) &&
(((!!b && (typeof b === 'object') && !Array.isArray(b)) && Object.keys(b).every(function(k){return ((typeof k === 'string') && (typeof b[k] === 'number'));}))) &&
(((typeof c === 'string') || (typeof c === 'number')))
```

### Usage

```bash
yarn add jsdoc-to-condition --dev
```

```js
import {parseType} from 'jsdoc-to-condition';

console.log(parseType(`{string} varName`)[0].validation);
// ((typeof varName === 'string'))
```

### Docs

For full reference on supported comment types see the `tests` folder.

### License

**MIT**

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