Skip to content

Commit

Permalink
add: update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
giovanesantossilva committed Jul 25, 2023
1 parent 4bd4904 commit 92cc24d
Showing 1 changed file with 59 additions and 2 deletions.
61 changes: 59 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

> JavaScript validation engine
![Version](https://img.shields.io/github/package-json/v/theonlyducks/validation.js)
![Project Size](https://img.shields.io/bundlephobia/min/@theonlyducks/validation.js@latest)
![Dependencies](https://img.shields.io/github/languages/top/theonlyducks/validation.js)
![Licence](https://img.shields.io/github/license/theonlyducks/validation.js)

## Table of contents

- [Getting started](#getting-started)
- [Documentation](#documentation)

## Documentation

See
Expand All @@ -16,8 +26,10 @@ yarn add @theonlyducks/valitaion.js

### Usage

#### Basic usage

```js
import Validate from "valitaion.js";
import Validate, { AssertError } from "valitaion.js";

const name = 'John Doe'
const props = new Validate();
Expand All @@ -27,6 +39,51 @@ try {
props.assertOne();
console.log('valid');
} catch (error) {
console.error('errors', errors.data);
if (error instanceof AssertError) {
console.error('errors', errors.data);
}
}
```

#### Advanced usage

```js
import Validate, { AssertError } from "valitaion.js";

const data = {
name: 'John Doe',
email: '[email protected]'
};

const validate = new Validate();
validate
.addKey('name').required().notEmpty().isString()
.addKey('email').required().notEmpty().isString().isEmail();

try {
validate.assert(data);
console.log('valid');
} catch (error) {
if (error instanceof AssertError) {
console.error('errors', errors.data);
}
}
```

## Development

Install

```shell
yarn
```

Run tests

```shell
yarn test
```

## License

[MIT](https://opensource.org/licenses/MIT) © [The Only Ducks](https://github.com/theonlyducks)

0 comments on commit 92cc24d

Please sign in to comment.