# @ezier/validate

> An ezier validator for nodejs.

Latest version **0.2.3** (published 2022-06-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ezier/validate
pnpm add @ezier/validate
yarn add @ezier/validate
bun add @ezier/validate
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.3 |
| Published | 2022-06-12 |
| First published | 2022-04-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Shadofer |
| Maintainers | shadofer |
| Keywords | ezier, validate, simple, nodejs, mocha, chai, swc, uuid, prettier |

## Links

- npm: https://www.npmjs.com/package/@ezier/validate
- Repository: https://github.com/ezier-project/validate
- Homepage: https://github.com/ezier-project/validate#readme
- Issues: https://github.com/ezier-project/validate/issues
- npm.io page: https://npm.io/package/@ezier/validate

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) ^17.0.25

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.2.3 (latest) — 2022-06-12
- 0.2.2 — 2022-04-27
- 0.2.1 — 2022-04-27
- 0.2.0 — 2022-04-27
- 0.1.0 — 2022-04-27
- 0.0.1 — 2022-04-25

## README

<h1 align='center'><img src='https://raw.githubusercontent.com/ezier-project/validate/master/images/validate.svg' alt='Ezier Validator logo'>

Ezier Validator</h1>

<h2 align='center'>An ezier validator for nodejs.</h2>

<h2 align='center'>

![npm bundle size](https://img.shields.io/bundlephobia/min/@ezier/validate?style=for-the-badge) ![npm](https://img.shields.io/npm/dm/@ezier/validate?style=for-the-badge) ![NPM](https://img.shields.io/npm/l/@ezier/validate?style=for-the-badge) ![npm](https://img.shields.io/npm/v/@ezier/validate?style=for-the-badge)

</h2>

# Why?

**This validator allows you to validate your objects with eze.
Nothing more, nothing less.**

***Also used in the Fronvo [server](https://github.com/Fronvo/fronvo)***

# Installing

```
npm i @ezier/validate
```

# Documentation
**Documentation for the Ezier Validator can be found at https://ezier-project.github.io/validate/.**

# Examples

**Validate a string's length:**

```ts
import { StringSchema } from '@ezier/validate';

const schema = new StringSchema({
    value: {
        minLength: 5,
        maxLength: 20
    }
});

const result = schema.validate({
    value: 'some string'
});
```

**Validating manually with regex:**

```ts
import { v4 } from 'uuid';

const uuidSchema = new StringSchema({
    uuid: {
        regex: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/
    },
});

uuidSchema.validate({ uuid: v4() });
```

**Or with provided types:**

```ts
import { v4 } from 'uuid';

const uuidSchema = new StringSchema({
    uuid: {
        type: 'uuid'
    },
});

uuidSchema.validate({ uuid: v4() });
```

**With support for optional fields:**

```ts
const schema = new StringSchema({
    provideThis: {
        minLength: 8,
        maxLength: 60,
        type: 'email',
    },

    orThis: {
        minLength: 8,
        maxLength: 30,
        regex: /^[a-zA-Z0-9]+$/,
        optional: true
    },
});

schema.validate({
    provideThis: 'anemail@gmail.com'
});
```

**Getting error info:**

```ts
for (const errorObjectIndex in result) {
    const errorObject = result[Number(errorObjectIndex)];

    console.log(`[${errorObject.name}]: ${errorObject.message}`);
}
```

**More examples located [here](https://github.com/ezier-project/validate/tree/master/examples)**

<i>Made by [Shadofer](https://github.com/shadofer) with joy.</i>

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