# validate-args-js

> Validate arguments to Javascript.

Latest version **1.1.0** (published 2018-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install validate-args-js
pnpm add validate-args-js
yarn add validate-args-js
bun add validate-args-js
```

## 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.1.0 |
| Published | 2018-04-18 |
| First published | 2018-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Kelvin Oenning |
| Maintainers | adapcon |

## Links

- npm: https://www.npmjs.com/package/validate-args-js
- Repository: https://github.com/Adapcon/validate-args-js
- Homepage: https://adapcon.com.br/
- Issues: https://github.com/Adapcon/validate-args-js/issues
- npm.io page: https://npm.io/package/validate-args-js

## Recent versions

- 1.1.0 (latest) — 2018-04-18
- 1.0.1 — 2018-04-18
- 1.0.0 — 2018-04-18

## README

# Validate-args-js

Validate arguments to Javascript.

[![Build Status](https://travis-ci.org/Adapcon/validate-args-js.svg?branch=master)](https://travis-ci.org/Adapcon/validate-args-js)

[![Coverage Status](https://coveralls.io/repos/github/Adapcon/validate-args-js/badge.svg?branch=master)](https://coveralls.io/github/Adapcon/validate-args-js?branch=master)

## Installation

```
npm install --save validate-args-js
```

## Usage

#### Import

``` js
const check = require('validate-args-js')
```

#### Simple
``` js
check.arg({ 
    arg: undefined, 
    err: 'err name' 
})

//Return -> throw new Error('err name')
```
``` js
check.arg({ 
    arg: undefined, 
    err: undefined 
})

//Return -> throw new Error('one argument has not been defined!')
```

#### Accept
``` js
check.arg({ 
    arg: undefined, 
    err: 'err name',
    accept: {
        options: [1,2,3],
        err: 'err accept name'
    }
})

//Return -> throw new Error('err name')
```
``` js
check.arg({ 
    arg: 4, 
    err: 'err name',
    accept: {
        options: [1,2,3],
        err: 'err accept name'
    }
})

//Return -> throw new Error('err accept name')
```
``` js
check.arg({ 
    arg: 4, 
    err: 'err name',
    accept: {
        options: [1,2,3],
        err: undefined
    }
})

//Return -> throw new Error('one argument has not been accepted!')
```

#### List
``` js
check.args([
    { 
        arg: 1, 
        err: 'err value',
        accept: {
            options: [1,2,3],
            err: 'err accept value'
        }
    },
    { 
        arg: 4, 
        err: 'err value 2',
        accept: {
            options: [1,2,3],
            err: 'err accept value 2'
        }
    }
])

//Return -> throw new Error('err accept value 2')
```

``` js
check.args([{ 
    arg: undefined, 
    err: 'err name',
    accept: {
        options: [1,2,3],
        err: 'err accept name'
    }
}])

//Return -> throw new Error('err name')
```

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