# persian-mongoose

> Persian localization and validation for mongoose

Latest version **1.0.1** (published 2019-06-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install persian-mongoose
pnpm add persian-mongoose
yarn add persian-mongoose
bun add persian-mongoose
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-06-14 |
| First published | 2019-06-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | AmirHasan Hesam |
| Maintainers | drehsan |
| Keywords | persian, mongoose, culture, localization |

## Links

- npm: https://www.npmjs.com/package/persian-mongoose
- Repository: https://github.com/DrEhsan/persian-mongoose
- Issues: https://github.com/DrEhsan/persian-mongoose/issues
- npm.io page: https://npm.io/package/persian-mongoose

## Dependencies (2)

- [mongoose](https://npm.io/package/mongoose.md) ^5.5.13
- [persianize](https://npm.io/package/persianize.md) ^2.0.0

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [btrz-health-check](https://npm.io/package/btrz-health-check.md) — 474 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-06-14
- 0.1.0 — 2019-06-07

## README

persian-mongoose
===================

persian localization and validation for mongoose schemas

for persian validation we use [persianize](https://github.com/opencafe/persianize-node) as validators.

## Installation

``` npm install persian-mongoose```

## Persian Validation

A set of validation for persian and Iran usages

| Function  | Description |
| ------------- | ------------- |
| isMobile      | check if string is following iran's mobile number formats   |
| isCardNumber  | check if string is a real iran bank card number             |
| isPhone       | check if string is iran's phone number format               |
| isPostalCode  | check if string following iran's postal code's format       |
| isSheba       | check if string is real sheba number                        |
| isMelliCode   | check if string is real melli code                          |

Example :

```javascript
var mySchema = new mongoose.Schema({
    phone_number : {
      type : String,
      validate: [
        { validator: persianMongoose.isMobile, msg: 'phone number is incorrect'}
      ]
    }
});
```

## Convertors

### removeArabicChars
This converts arabic alphabet characters to persian characters

Example (convert arabic chars to persian) :


```javascript

//Input : فارسي   -> Ouput : فارسی

Schema.plugin(persianMongoose.removeArabicChars,
{
    removeArabicChars:
    {
        fields : ['name']
    }
});
```

## Complete Usage

```javascript

var mySchema = new mongoose.Schema({
    name: {type: String}
});

mySchema.plugin(persianMongoose.removeArabicChars,
{
    removeArabicChars:
    {
        fields : ['name']
    }
});

var myModel = mongoose.model('myModel', mySchema);

var newName = new myModel({ name : 'علي' });

newName.save(function (err) {

  if (err)
    console.log(err)

  // saved!
});
// will save { name : 'علی' }
```

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