Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/slekup/builder-validation
A minimalist validation library for JavaScript.
https://github.com/slekup/builder-validation
builders classes nodejs schema validate validation
Last synced: 16 days ago
JSON representation
A minimalist validation library for JavaScript.
- Host: GitHub
- URL: https://github.com/slekup/builder-validation
- Owner: slekup
- License: mit
- Created: 2023-06-09T08:17:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-18T13:25:08.000Z (12 months ago)
- Last Synced: 2024-10-10T14:44:55.746Z (27 days ago)
- Topics: builders, classes, nodejs, schema, validate, validation
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/builder-validation
- Size: 301 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Builder Validation Logo](https://i.imgur.com/RCbaMSq.png)](https://github.com/slekup/builder-validation)
---
Express Custom • Discord • GitHub
---
A minimalist validation library for JavaScript.
[![Discord Server](https://img.shields.io/discord/1028009131073880104?color=5865F2&logo=discord&logoColor=white)](https://discord.gg/p5rxxQN7DT)
![NPM Version](https://img.shields.io/npm/v/builder-validation.svg) ![NPM Downloads](https://img.shields.io/npm/dt/builder-validation) ![Test Status](https://github.com/slekup/builder-validation/actions/workflows/tests.yml/badge.svg) ![NPM Size](https://img.shields.io/bundlephobia/min/builder-validation)---
A minimalist validation library for JavaScript. Builder validation is a library that provides classes to build and validate objects against a schemas. It can be useful if you don't want to define your own regexes or functions to validate objects.
This library is also a part of the [express-custom](https://npmjs.com/package/express-custom) library, which is what this library was originally made for.
> **Warning:** This library is still in development and is not ready for production use. There may be breaking changes in the future.
## Installation
```bash
# Using npm
> npm install builder-validation
# Using yarn or pnpm
> yarn/pnpm add builder-validation
```## Usage
### Importing
This library supports both typescript and javascript, with ES6 modules and CommonJS.
```ts
// ES6 modules
import { Schema } from 'builder-validation';
// CommonJS
const { Schema } = require('builder-validation');
```### Create the Schema
The first step is to create the schema. The schema is the object that will be used to validate the object.
```ts
const schema = new Schema()
.addString({
name: 'username',
required: true,
minLength: 3,
maxLength: 16,
})
.addString({
name: 'password',
required: true,
minLength: 8,
maxLength: 32,
});
```### Validate an object
```ts
schema.validate({
username: 'slekup',
password: 'password',
});
```## Issues and Contributing
If you have any issues or would like to contribute, please [open an issue](https://github.com/slekup/builder-validation/issues/new) or pull request.
## License
Copyright © [slekup](https://github.com/slekup)