# truthjs

> validation library

Latest version **1.1.0** (published 2019-02-08) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2019-02-08 |
| First published | 2019-01-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Hoang Tran |
| Maintainers | hayden.tran.d |

## Links

- npm: https://www.npmjs.com/package/truthjs
- Repository: https://github.com/hoangtranson/truejs
- Homepage: https://github.com/hoangtranson/truejs#readme
- Issues: https://github.com/hoangtranson/truejs/issues
- npm.io page: https://npm.io/package/truthjs

## Recent versions

- 1.1.0 (latest) — 2019-02-08
- 1.0.0 — 2019-01-14

## README

# truthjs

[![Maintainability](https://api.codeclimate.com/v1/badges/651c8c4d5473ebf905b2/maintainability)](https://codeclimate.com/github/hoangtranson/truejs/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/651c8c4d5473ebf905b2/test_coverage)](https://codeclimate.com/github/hoangtranson/truejs/test_coverage)

**truthjs** is a javascript validator library for:

- Number
- Array (future support)
- Boolean (future support)
- Email (future support)
- Network (future support)
- Object (future support)
- String (future support)

truthjs was implemented by functional approach by creating validator composable.

> truthjs uses recent ES features. It is tested on stable Node. If you need to support legacy browsers consider using a transpiler with polyfills.

## Installation

truthjs can be installed using npm.

```bash
npm install --save truthjs
```

For the complete code including all tests the repo can be cloned.

```bash
git clone https://github.com/hoangtranson/truejs.git
cd truejs
npm run test
```

## Getting Started

The `truthjs` function composes the validator to a single validator function. The validator are run in order, if one returns false the following functions will not be run.

In this example the age:

- Must be a number.
- Must be a integer.
- Must between 1 and 100.

```javascript
const truth = require("truthjs");
const { isNumber, isInteger, between } = require("truthjs/number");
const ageValidator = truth(isNumber(), isInteger(), between(1, 100));

ageValidator(5);
ageValidator(-10);
ageValidator(1.0);
```

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