# Persian Helper

### A package for the Persian programmer community and validation, correction and production of Persian strings or Iranian cases

[![npm version](https://img.shields.io/npm/v/persianhelper.svg?style=flat-square)](https://www.npmjs.org/package/persianhelper)
[![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=persianhelper&query=$.install.pretty&label=install%20size&style=flat-square)](https://packagephobia.now.sh/result?p=persianhelper)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/persianhelper?style=flat-square)](https://bundlephobia.com/package/persianhelper@latest)
[![npm downloads](https://img.shields.io/npm/dm/persianhelper.svg?style=flat-square)](https://npm-stat.com/charts.html?package=persianhelper)
[![jsDeliver](https://data.jsdelivr.com/v1/package/npm/persianhelper/badge)](https://www.jsdelivr.com/package/npm/persianhelper)

# Installing

## Package manager

### Using npm:

```bash
 npm install persianhelper
```

### Using yarn:

```bash
 yarn add persianhelper
```

# Usage/Examples

Once the package is installed, you can import the library using import or require approach:

```javascript
import {
  arabicToPersian,
  isFullName,
  generateNationalCode,
  phoneNumberInfo,
} from "persianhelper";
```

```javascript
const persianHelper = require("persianhelper");
```

# Parser :

You can parse Arabic number and characters to Persian number and characters

## Character :

Conver Characters

### Arabic to Persian :

convert all Arabic characters to Persian Charaters

```javascript
import { arabicToPersian } from "persianhelper";

arabicToPersian("جُمُعَةِ"); // "جمعه"
arabicToPersian("يحيي ١٤٩"); // "یحیی ۱۴۹"
```

### SwitchKey :

convert all Persian or Arabic Characters to English Character in keyboard

```javascript
import { switchKey } from "persianhelper";

switchKey("لخخلمث.زخئ"); // "google.com"
```

### HalfSpace :

add half space to the text

```javascript
import { halfSpace } from "persianhelper";

halfSpace("این متن تست می باشد."); // "این متن تست می‌باشد."
```

## Number :

Parse the number to anything you want

### Arabic, Persian to English :

Parse the Persian number to English number

```javascript
import { numberToEnglish } from "persianhelper";

numberToEnglish("۰۱۲۳۴۵۶۷۸۹"); // "0123456789"
```

### Seperate Number :

Parse the number to price number

```javascript
import { seperateNumber } from "persianhelper";

seperateNumber("1200000000"); // -> return -> "1,200,000,000"

seperateNumber("۱۳۴۵۲۳۴۴۰"); // "134,523,440"
```

### Number To word :

Parse the Number to Persian word

```javascript
import { numberToWord } from "persianhelper";

numberToWord(10564523); // "ده میلیون و پانصد و شصت و چهار هزار و پانصد و بیست و سه"
```

# Validation :

You can validate your string and anything this time I added to this package

## String Input :

Checking String Input thing

### FullName :

Check fullName, If it's valid return true otherwise return false

```javascript
import { isFullName } from "persianhelper";

isFullName("علی"); // false
isFullName("علی محمدی"); // true
```

### Date Time :

Check Date and Time, If it's valid return true otherwise return false

```javascript
import { isDate, isTime, isDateTime } from "persianhelper";

isDate("1402/06/20"); // true
isTime("21:06"); // true
isDateTime("1402/06/20 21:06"); // true
```

### Email :

Check Email, If it's valid return true otherwise return false

```javascript
import { isEmail } from "persianhelper";

isEmail("test@gmail.com"); // true
```

## NationalId NationaCode :

Valid and generate NationalId and NationaCode

### Validator :

Check NationalId and NationalCode, If it's valid return true otherwise return false
(NationalId for legal entities and NationalCode for real people)

```javascript
import { isNationalId, isNationalCode } from "persianhelper";

isNationalId("14007650912"); // true
isNationalCode("8497548795"); // true
```

### Generate :

Generate NationalCode

```javascript
import {
  generateNationalCode,
  generateNationalCodeRound,
  placeOfNationalCode,
} from "persianhelper";

generateNationalCode(); // "8497548795"
generateNationalCodeRound(); // "8000011018"
placeOfNationalCode("442"); // { city: 'یزد', province: 'یزد', codes: [ '442', '443' ] }
```

### Postal Code :

Check PostalCode, If it's valid return province and city of postalCode

```javascript
import { postalCodeInfo } from "persianhelper";

postalCodeInfo("891");
/*  
{
  code: 891,
  city: 'یزد',
  cityEnglishName: 'Yazd',
  provinceId: 31,
  province: 'یزد',
  originLat: '31.88352203369140',
  originLng: '54.34774017333980'
}
 */
```

### PlateNumber :

Check plateNumber, If it's valid return province and city of postalCode

```javascript
import { plateNumberInfo } from "persianhelper";

plateNumberInfo({ numbers: "1132144", char: "ج" });
/*  
{
  type: 'Car',
  template: '11ج321ایران44',
  details: {
    firstTwoDigits: '11',
    plateCharacter: 'ج',
    nextThreeDigits: '321',
    provinceCode: '44'
  },
  province: 'تهران',
  category: 'شخصی'
}
 */
```

### PhoneNumber :

Check phoneNumber and If it's valid return province and city of postalCode

```javascript
import { isPhoneNumber, phoneNumberInfo } from "persianhelper";

isPhoneNumber("09124446677"); // true
phoneNumberInfo("09124446677");
/*  
{
  province: [
    'البرز',
    'زنجان',
    'سمنان',
    'قزوین',
    'قم',
    'برخی از شهرستان های استان مرکزی'
  ],
  base: 'تهران',
  type: [ 'دائمی' ],
  operator: 'همراه اول'
}
 */
```

### Banking :

Check shebaNumber, bankNameCard and If it's valid return bankName and other info

```javascript
import { shebaNumberInfo, bankNameCard, isShebaNumber } from "persianhelper";

isShebaNumber("IR270170000000100324200001"); // true
bankNameCard("504172"); // "بانک رسالت"
shebaNumberInfo("IR270170000000100324200001");
/*  
{
  code: '017',
  nickname: 'melli',
  name: 'Melli',
  persianName: 'بانک ملی ایران',
  accountNumberAvailable: false
}
 */
```
