# rulingjs

> Just a simple set of useful functions to check validation rules

Latest version **1.1.0** (published 2023-09-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install rulingjs
pnpm add rulingjs
yarn add rulingjs
bun add rulingjs
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2023-09-15 |
| First published | 2021-11-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 23.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Victor Castro-Cintas |
| Maintainers | vcastro45 |

## Links

- npm: https://www.npmjs.com/package/rulingjs
- Repository: https://github.com/vcastro45/rulingjs
- Homepage: https://github.com/vcastro45/rulingjs#readme
- Issues: https://github.com/vcastro45/rulingjs/issues
- npm.io page: https://npm.io/package/rulingjs

## Recent versions

- 1.1.0 (latest) — 2023-09-15
- 1.0.0 — 2022-05-30
- 0.2.5 — 2022-03-21
- 0.2.4 — 2022-02-15
- 0.2.3 — 2021-12-21
- 0.2.2 — 2021-12-19
- 0.2.1 — 2021-12-19
- 0.2.0 — 2021-11-22
- 0.1.3 — 2021-11-20
- 0.1.2 — 2021-11-18
- 0.1.1 — 2021-11-16
- 0.1.0 — 2021-11-16

## README

# RulingJs

Just a simple set of useful functions to check validation rules

[![npm](https://img.shields.io/npm/v/rulingjs.svg)](https://www.npmjs.com/package/rulingjs)

## Install

```bash
npm i -S rulingjs
```

## To Do List

- ~~Translate in multiple languages~~
- Automate NPM publication with CI/CD pipeline
- ~~Add tests~~

## Usage 
Instanciating a rule
```typescript
// Basic rule
const requiredRule = ruling.required()

// Rule with custom error message
const requiredRule = ruling.required('This is a mandatory field, dude !')
```

Change language
```typescript
import ruling from 'ruling'
import fr from 'ruling/locale/fr.js'

const rulingFr = ruling.create({
      lang: fr
    })

const requiredRule = rulingFr.required()
```

Use a rule with Vuetify
```vue
<template>
  <v-text-field label="Your email"
                :rules="[ruling.required(), ruling.email()]"
  />
</template>
```

## Rules

### `email`
```typescript
ruling.email(customErrorMessage?: string)
```

### `isCapital`
```typescript
ruling.isCapital(customErrorMessage?: string)
```

### `isNumber`
```typescript
ruling.isNumber(customErrorMessage?: string)
```

### `isInteger`
```typescript
ruling.isInteger(customErrorMessage?: string)
```

### `isCapitalOrNumber`
```typescript
ruling.isCapitalOrNumber(customErrorMessage?: string)
```

### `isDefined`
```typescript
ruling.isDefined(customErrorMessage?: string)
```

### `maxLength`
```typescript
ruling.maxLength(len: number, customErrorMessage?: string)
```

### `minLength`
```typescript
ruling.minLength(len: number, customErrorMessage?: string)
```

### `NotContain`
```typescript
ruling.NotContain(forbiddenCharacters: string[], customErrorMessage?: string)
```

### `notEmpty`
```typescript
ruling.notEmpty(customErrorMessage?: string)
```

### `required`
```typescript
ruling.required(customErrorMessage?: string)
```

### `strictLength`
```typescript
ruling.strictLength(len: number, customErrorMessage?: string)
```

### `pattern`
```typescript
ruling.pattern(pattern: RegExp, customErrorMessage?: string)
```

## Thanks

Thanks to [@Vincere1st](https://github.com/Vincere1st) for contributions

## License

[MIT](http://opensource.org/licenses/MIT)

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