# number-validation

> Numerical validation.

Latest version **1.1.1** (published 2019-06-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install number-validation
pnpm add number-validation
yarn add number-validation
bun add number-validation
```

## 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.1 |
| Published | 2019-06-17 |
| First published | 2019-06-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | FreeIntelligence |
| Maintainers | freeintelligence |
| Keywords | number, validation, validator |

## Links

- npm: https://www.npmjs.com/package/number-validation
- Repository: https://github.com/freeintelligence/js-number-validation
- Homepage: https://github.com/freeintelligence/js-number-validation#readme
- Issues: https://github.com/freeintelligence/js-number-validation/issues
- npm.io page: https://npm.io/package/number-validation

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2019-06-17
- 1.1.0 — 2019-06-15
- 1.0.0 — 2019-06-14

## README

# number-validation

Project created with Nalv CLI.

```sh
$ npm install @nalv/cli -g
$ nalv new name-your-app
```

Install with:

```sh
$ npm install number-validation
```

## Transform class (instance methods)
```js
constructor(private decimalSeparator: string = '.', private thousandSeparator: string = ',')

const transform = new Transform('.', ',') // to 9,999.9 format
const transform2 = new Transform(',', '.') // to 9.999,9 format
```
### min
```js
min(text: string | number, min: string | number)

transform.min('9,000', 12000) // "12,000" (12000 > 9000)
transform.min('19,000', 12000) // "19,000" (12000 < 19000)
transform.min('19,000', '55,000') // "55,000" (55000 > 19000)

transform2.min('9.000', 12000) // "12.000" (12000 > 9000)
transform2.min('19.000', 12000) // "19.000" (12000 < 19000)
transform2.min('19.000', '55.000') // "55.000" (55000 > 19000)
```
### max
```js
max(text: string | number, max: string | number)

transform.max('9,000', 12000) // "9,000" (12000 > 9000)
transform.max('19,000', 12000) // "12,000" (12000 < 19000)
transform.max('19,000', '55,000') // "19,000" (55000 > 19000)

transform2.max('9.000', 12000) // "9.000" (12000 > 9000)
transform2.max('19.000', 12000) // "12.000" (12000 < 19000)
transform2.max('19.000', '55.000') // "19.000" (55000 > 19000)
```
### onlyValid
```js
onlyValid(text: string | number)

transform.onlyValid('-9,000abc') // "-9,000"
transform.onlyValid('19,000.2c') // "19,000.2"
```
### eliminateThousands
```js
eliminateThousands(text: string | number)

transform.eliminateThousands('9,000.2') // "9000.2"
transform.eliminateThousands('19.000,2') // "19000,2"
```
### toInt
```js
toInt(text: string | number)

transform.toInt(9000.2) // 9000.2
transform.toInt('19000,2') // 19000.2
```
### format
```js
format(text: string | number)

transform.format(9000.2) // "9,000.2"
transform.format('19000,2') // "19.000,2"
```

## Utils class (static methods)
```js
toInt(text, decimalSeparator)

Utils.toInt('100,92', ',') // 100.92
Utils.toInt('100.92', '.') // 100.92
```
```js
toTextInt(text, decimalSeparator)

Utils.toTextInt('-100,92', ',') // "-100.92"
Utils.toTextInt('-100.92', '.') // "-100.92"
```

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