Skip to content

Commit

Permalink
feat(nationalId):added (Validating Iranians national id) feature
Browse files Browse the repository at this point in the history
* test(nationalId):added verify input and nationalId

* feat(nationalId):added verifyIranianNationalId getter

* improvement(nationalId):added nation id example and update README.md

* improvement(readme):update README.md

* improvement(readme):update README.md

Co-authored-by: Ehsan Aramide <[email protected]>
  • Loading branch information
payam-zahedi and EhsanAramide authored Mar 25, 2021
1 parent 3eefb29 commit 19efe02
Show file tree
Hide file tree
Showing 16 changed files with 393 additions and 130 deletions.
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

188 changes: 94 additions & 94 deletions .idea/libraries/Dart_Packages.xml

Large diffs are not rendered by default.

41 changes: 20 additions & 21 deletions .idea/libraries/Dart_SDK.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/markdown-navigator-enh.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions .idea/markdown-navigator.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 120 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
- [ ] Adding and removing separator to/from numbers
- [x] [Converting Persian numbers to Arabic / English numbers and reverse](#converting-persian-numbers-to-arabic--english-numbers-and-reverse---source)
- [x] [Checking a string has/is Persian](#checking-a-string-hasis-persian---source)
- [ ] Validating Iranians national id
- [x] [Validating Iranians national id](#validate-iranian-national-numbercode-e-melli---source)
- [ ] Finding city and province names by national id
- [x] [Calculating bills](#calculating-bill---source)
- [ ] Checking IBAN of the bank account (_SHEBA_)
- [x] [Validating ATM card number](#validating-atm-card-number---source)
- [ ] Finding name of banks by ATM card number
- [ ] Getting information from vehicle plate
- [x] [Fixing and decoding URLs with whitespace](#fixing-and-decoding-urls---source)
- [x] [Fixing and decoding URLs with whitespace](https://github.com/persian-tools/dart-persian-tools#fixing-and-decoding-urls---source)
## Usage

now let's look at examples and how work with apis in package
Expand Down Expand Up @@ -58,7 +58,124 @@ isPersian('هل هذا نص فارسي؟'); // false
hasPersian('This text includes فارسی'); // true
hasPersian('Это персидский س текст?'); // true
hasPersian('أكد رئيس اللجنة العسكرية الممثلة لحكومة الوفاق أراضي البلاد.'); //true
```
```

- #### Validate Iranian national number(code-e Melli) - [source](https://github.com/persian-tools/dart-persian-tools/blob/master/lib/sac/national_id.dart)

```dart
verifyIranianNationalId('0684159414'); // true
///the nationalID should contain 10 digit, so the following verifications
/// <div align="center">
<p align="center">
<img src="https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png" width="200" />
</p>
<h1 align="center">Persian tools</h1>
<p align="center">Persian Tools dart package which you can use in all platforms</p>
[![MIT license](https://img.shields.io/badge/License-MIT-lightblue.svg)](https://github.com/persian-tools/dart-persian-tools/blob/master/LICENSE)
[![codecov](https://codecov.io/gh/persian-tools/dart-persian-tools/branch/master/graph/badge.svg?token=2O5UD1VRHN)](https://codecov.io/gh/persian-tools/dart-persian-tools)
[![CI/CD](https://github.com/persian-tools/dart-persian-tools/workflows/Test%20master/badge.svg)]()
[![Dart Version](https://img.shields.io/badge/Dart-v2.12.0-lightblue)](https://dart.dev)
![status](https://img.shields.io/badge/under_development-lightblue.svg)
</div>
<hr/>
## Features
- [x] [Adding ordinal suffixes](#adding-ordinal-suffixes---source)
- [ ] Converting Persian words to number
- [ ] Converting Persian numbers to word
- [ ] Adding and removing separator to/from numbers
- [x] [Converting Persian numbers to Arabic / English numbers and reverse](#converting-persian-numbers-to-arabic--english-numbers-and-reverse---source)
- [x] [Checking a string has/is Persian](#checking-a-string-hasis-persian---source)
- [x] [Validating Iranians national id](#validate-iranian-national-numbercode-e-melli---source)
- [ ] Finding city and province names by national id
- [x] [Calculating bills](#calculating-bill---source)
- [ ] Checking IBAN of the bank account (_SHEBA_)
- [x] [Validating ATM card number](#validating-atm-card-number---source)
- [ ] Finding name of banks by ATM card number
- [ ] Getting information from vehicle plate
- [x] [Fixing and decoding URLs with whitespace](https://github.com/persian-tools/dart-persian-tools#fixing-and-decoding-urls---source)
## Usage
now let's look at examples and how work with apis in package
- #### Adding Ordinal Suffixes - [source](https://github.com/persian-tools/dart-persian-tools/blob/master/lib/src/add_ordinal_suffix.dart)
```dart
var number = 'سی سه'; // or سی | شصت | پنجاه دو
addOrdinalSuffix(number); // سی سوم | سی اُم | شصتم | پنجاه دوم
number.withOrdinalSuffix // ... like so
```

- #### Converting Persian numbers to Arabic / English numbers and reverse - [source](https://github.com/persian-tools/dart-persian-tools/blob/master/lib/src/Digits/methods.dart)

```dart
convertArToFa('السلام علیکم 14۱۲۳6٤٥'); // السلام علیکم 14۱۲۳6۴۵
convertArToEn('Persian Tools : 123٥٦٧'); // Persian Tools : 123567
convertEnToFa('سلام این هارو فارسی کن : 22۲۳۴'); // سلام این هارو فارسی کن : ۲۲۲۳۴
convertFaToEn('سلام این هارو اینگلیسی کن : 22۲۳۴'); // سلام این هارو اینگلیسی کن : 22234
```

- #### Checking a string has/is Persian - [source](https://github.com/persian-tools/dart-persian-tools/blob/master/lib/src/isPersian/methods.dart)

```dart
isPersian('این یک متن فارسی است؟'); // true
isPersian('هل هذا نص فارسي؟'); // false
hasPersian('This text includes فارسی'); // true
hasPersian('Это персидский س текст?'); // true
hasPersian('أكد رئيس اللجنة العسكرية الممثلة لحكومة الوفاق أراضي البلاد.'); //true
```

- #### Validate Iranian national number(code-e Melli) - [source](https://github.com/persian-tools/dart-persian-tools/blob/master/lib/sac/national_id.dart)

```dart
verifyIranianNationalId('0684159414'); // true
/// the nationalID should contain 10 digit, so the following verifications
/// should return false
verifyIranianNationalId('00000'); // false
/// use extension function
'0684159414'.isIranianNationalId; // true
```

- #### Calculating Bill - [source](https://github.com/persian-tools/dart-persian-tools/blob/master/lib/src/bill.dart)

```dart
var bill = Bill(billId: 9174639504124, paymentId: 12908197, currency: 'rial');
bill.barcode // 917463950412400012908197
bill.billType // برق
bill.amount // 129000
bill.isBillValid // false
bill.isPaymentIdValid // false
bill.isBillIdValid // true
// returns all the above getter as a Map with same as getters
bill();
```

- #### Validating ATM card number - [source](https://github.com/persian-tools/dart-persian-tools/blob/master/lib/src/validate_card_number.dart)

```dart
validateCardNumber('6219861034529007'); // true
validateCardNumber('6219861034529007'); // true
validateCardNumber('0000000000000000'); // false
validateCardNumber('621986103452900'); // false
```

- #### Fixing and decoding URLs - [source](https://github.com/persian-tools/dart-persian-tools/blob/master/lib/src/url_fix.dart)

```dart
var url = 'wss://hostname.domain/?q=i am a wrong query';
urlFix(url); // wss://hostname.domain/?q=i%20am%20a%20wrong%20query
```
should return false
verifyIranianNationalId('00000'); // false

/// use extension function
'0684159414'.isIranianNationalId; // true
```
- #### Calculating Bill - [source](https://github.com/persian-tools/dart-persian-tools/blob/master/lib/src/bill.dart)
Expand Down
5 changes: 3 additions & 2 deletions dart-persian-tools.iml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
Expand Down
2 changes: 1 addition & 1 deletion example/example_bill.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ void main() {
print(bill.isBillIdValid); // true
// returns all the above getter as a Map with same as getters
print(bill());
}
}
6 changes: 4 additions & 2 deletions example/example_digits_methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:dart_persian_tools/dart_persian_tools.dart';
void main() {
print(convertArToFa('السلام علیکم 14۱۲۳6٤٥')); // السلام علیکم 14۱۲۳6۴۵
print(convertArToEn('Persian Tools : 123٥٦٧')); // Persian Tools : 123567
print(convertEnToFa('سلام این هارو فارسی کن : 22۲۳۴')); // سلام این هارو فارسی کن : ۲۲۲۳۴
print(convertFaToEn('سلام این هارو اینگلیسی کن : 22۲۳۴')); // سلام این هارو اینگلیسی کن : 22234
print(convertEnToFa(
'سلام این هارو فارسی کن : 22۲۳۴')); // سلام این هارو فارسی کن : ۲۲۲۳۴
print(convertFaToEn(
'سلام این هارو اینگلیسی کن : 22۲۳۴')); // سلام این هارو اینگلیسی کن : 22234
}
3 changes: 2 additions & 1 deletion example/example_ispersian_methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ void main() {
print(isPersian('هل هذا نص فارسي؟')); // false
print(hasPersian('This text includes فارسی')); // true
print(hasPersian('Это персидский س текст?')); // true
print(hasPersian('أكد رئيس اللجنة العسكرية الممثلة لحكومة الوفاق أراضي البلاد.')); //true
print(hasPersian(
'أكد رئيس اللجنة العسكرية الممثلة لحكومة الوفاق أراضي البلاد.')); //true
}
14 changes: 14 additions & 0 deletions example/example_national_id.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:dart_persian_tools/dart_persian_tools.dart';

void main() {
var nationalID = '0684159414';
print(verifyIranianNationalId(nationalID)); // true

///the nationalID should contain 10 digit, so the following verifications
///should return false
nationalID = '00000';
print(verifyIranianNationalId(nationalID)); // false

nationalID = '';
print(nationalID.isIranianNationalId); // false
}
4 changes: 2 additions & 2 deletions example/example_validate_card_number.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:dart_persian_tools/dart_persian_tools.dart';

void main(){
void main() {
print(validateCardNumber('6219861034529007')); // true
print(validateCardNumber('6219861034529007')); // true
print(validateCardNumber('0000000000000000')); // false
print(validateCardNumber('621986103452900')); // false
}
}
3 changes: 3 additions & 0 deletions lib/dart_persian_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ export 'src/core/validate_card_number/validate_card_number.dart';

// exports Digits methods
export 'src/core/digits/methods.dart';

// exports [NationalId] extension and
export 'src/core/national_id/national_id.dart';
Loading

0 comments on commit 19efe02

Please sign in to comment.