# validator_task

> Validator task is a library for optimize and make a order to the validations action in any siscurtance.

Latest version **1.0.0** (published 2018-05-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install validator_task
pnpm add validator_task
yarn add validator_task
bun add validator_task
```

## 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 | 2018-05-21 |
| First published | 2018-05-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ayevaml@gmail.com |
| Maintainers | ayevan |

## Links

- npm: https://www.npmjs.com/package/validator_task
- npm.io page: https://npm.io/package/validator_task

## Recent versions

- 1.0.0 (latest) — 2018-05-21

## README

validator task is a library for optimize and make a order to the validations action in any siscurtance.

validator argument
```
{
    "validator":reqired_string|string_regexp|function: return false|true,
    "message":"show this message with the validator will be false"
 }
 ```

**Examples**

use validate_elem
```js
const validator_task = require('validator_task');

let flags = [
    {
        "validator": "\\w",
        "message": "regex with validator string"
    },
    {
        "validator": /\d/,
        "message": "regex false"
    },
    {
        "validator": (params) => {
            return false
        },
        "message": "when the funtion returned false"
    },
];

console.log(validator_task.validate_elem(flags));
```
out
```js
[ 'regex false', 'when the funtion returned false' ]
```

<hr>

use validate_payload
```js
const validator_task = require('validator_task');

let payload = {
    "some key": {
        "value": "string",
        "flags": [
            {
                "validator": "required",
                "message": "value required"
            },
            {
                "validator": /\w/,
                "message": "regex"
            },
            {
                "validator": /\d/,
                "message": "regex false"
            },
            {
                "validator": (params) => {
                    return false
                },
                "message": "when the funtion returned false"
            },
        ]
    }
};

console.log(valid.validate_payload(payload));
```
out
```js
{ 'some key': [ 'regex false', 'when the funtion returned false' ] }
```
<hr>

use validate_body
```js
const validator_task = require('validator_task');

payload = {
    "some key": [
        {
            "validator": "required",
            "message": "value required"
        },
        {
            "validator": /\w/,
            "message": "regex"
        },
        {
            "validator": (params) => {
                return false
            },
            "message": "when the funtion returned false"
        }
    ]
};

let body = {
    "some key": "some string"
}

console.log(valid.validate_body(body, payload));
```
out
```js
{ 'some key': [ 'when the funtion returned false' ] }
```

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