# tn-validate

Latest version **4.1.5** (published 2025-12-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install tn-validate
pnpm add tn-validate
yarn add tn-validate
bun add tn-validate
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.1.5 |
| Published | 2025-12-08 |
| First published | 2020-05-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 22.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Turnova |
| Maintainers | turnova |

## Links

- npm: https://www.npmjs.com/package/tn-validate
- Repository: https://github.com/JawadAhbab/tn-validate
- npm.io page: https://npm.io/package/tn-validate

## Dependencies (3)

- [tn-consoler](https://npm.io/package/tn-consoler.md) ^2.2.0
- [tn-typescript](https://npm.io/package/tn-typescript.md) ^2.1.5
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.28.4

## Recent versions

- 4.1.5 (latest) — 2025-12-08
- 4.1.4 — 2024-03-15
- 4.1.3 — 2023-12-26
- 4.1.2 — 2023-12-26
- 4.1.1 — 2023-12-26
- 4.1.0 — 2023-12-26
- 4.0.0 — 2023-02-07
- 3.1.5 — 2021-05-10
- 3.1.4 — 2020-08-15
- 3.1.3 — 2020-07-09
- 3.1.2 — 2020-07-09
- 3.1.1 — 2020-07-06
- 3.1.0 — 2020-07-05
- 3.0.1 — 2020-06-23
- 3.0.0 — 2020-06-22
- … 6 more at https://npm.io/package/tn-validate/versions

## README

## Main module - `validate()`

```ts
import { validate } from 'tn-validate'

const value: any
const criteria: Criterion[]

validate(value, ...criteria)
```

## Singular Modules

_Better **TypeScript** Support with singular modules_

- `isString()`
- `isSymbol()`
- `isNumber()`
- `isBoolean()`
- `isFunction()`
- `isUndefined()`
- `isNull()`
- `isArray()`
- `isObject()`
- `isRegExp()`
- `isDate()`
- `isValidDate()`
- `isJson()`
- `isNumString()`
- `isArrObject()`
- `isNullUndefined()`
- `isStrArr()`
- `isNumArr()`
- `isBoolArr()`
- `isNumStrArr()`

## Type `Criterion`

```ts
type CustomValidator = (value: number) => boolean

type Criterion =
  | 'string'
  | StringConstructor
  | 'number'
  | NumberConstructor
  | 'boolean'
  | BooleanConstructor
  | 'function'
  | FunctionConstructor
  | 'array'
  | ArrayConstructor
  | 'object'
  | ObjectConstructor
  | 'regexp'
  | RegExpConstructor
  | 'date'
  | DateConstructor
  | 'valid-date'
  | 'json'
  | 'null'
  | 'undefined'
  | RegExp
  | CustomValidator
```

# Examples

```ts
validate('any')
validate('string', String)
validate('school', String, Boolean)
validate(50, Number, val => val > 0 && val < 100)
validate('{}', 'json')
validate(/^\w+$/, RegExp)
validate('foo-bar', /^foo-.+/)
```

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