# @innotrade/enapso-args

> Enapso Smart Arguments Processor

Latest version **1.0.1** (published 2020-02-07) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @innotrade/enapso-args
pnpm add @innotrade/enapso-args
yarn add @innotrade/enapso-args
bun add @innotrade/enapso-args
```

## 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.1 |
| Published | 2020-02-07 |
| First published | 2019-12-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 16.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alexander Schulze |
| Maintainers | alexander-schulze |
| Keywords | enapso, arguments, validation, typecheck, transformation, javascript |

## Links

- npm: https://www.npmjs.com/package/@innotrade/enapso-args
- Repository: https://github.com/innotrade/enapso-args
- Homepage: https://github.com/innotrade/enapso-args#readme
- Issues: https://github.com/innotrade/enapso-args/issues
- npm.io page: https://npm.io/package/@innotrade/enapso-args

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2020-02-07
- 1.0.0 — 2020-02-04
- 0.2.1 — 2020-02-04
- 0.2.0 — 2020-01-31
- 0.1.1 — 2019-12-13
- 0.1.0 — 2019-12-13

## README

# Enapso Smart Arguments Processor

You can either pass a single object as arguments or the arguments in the defined order.


## Why to use the Enapso Smart Arguments Processor?

You avoid unexpected results due to wrong or missing arguments or due to wrong argument order.
You can specify defaults for missing arguments and valdiate your arguments against a given schema.


## Installation
```
npm i @innotrade/enapso-args --save
```

## Usage

## Initialization
```javascript
const
    { EnapsoArguments } = require('@innotrade/enapso-args')
    ;

global.enargs = new EnapsoArguments();
global.enGetArgs = enargs.getArgs;
```

## Arg Validation Schema
```javascript
const
    schemaSingleStringArg = {
        args: [
            {
                "identifier": "text",
                "type": "string",
                "required": false,
                "default": "default value",
                "minLength": 0,
                "maxLength": 20
            }
        ]
    };
```
## Argument Validation
```javascript

function demoSingleStringArg(/*text*/) {
    let args = enGetArgs(arguments, schemaSingleStringArg, logValidationViolation);
    console.log('demoSingleStringArg: ' + args.text);
}

function demo() {
    demoSingleStringArg("Test");
    demoSingleStringArg(1);
    demoSingleStringArg(true);
    demoSingleStringArg();
}
```
## Output
```
demoSingleStringArg: Test
Error: Argument 'text' must be of type 'string' but is of type 'number'. Value: 1
demoSingleStringArg: 1
Error: Argument 'text' must be of type 'string' but is of type 'boolean'. Value: true
demoSingleStringArg: true
demoSingleStringArg: default value
```

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