Dart language version of Persian-Tools

Overview

Persian tools

Persian Tools dart package which you can use in all platforms

MIT license codecov CI/CD Dart Version status


Features

Usage

now let's look at examples and how work with apis in package

var number = 'سی سه'; // or سی | شصت | پنجاه دو
addOrdinalSuffix(number); // سی سوم | سی اُم | شصتم | پنجاه دوم
number.withOrdinalSuffix // ... like so
  • Adding and removing separator to / from numbers - source

addCommas('3333'); // 3,333
addCommas('۸۲۳۳۴۵'); // 823,345

removeCommas('654,562'); // 654562
removeCommas('3,365.255'); // 3365.255

'11222'.addComma // 11,222
'4,544.562'.removeComma // 4544.562
  • Converting Persian numbers to Arabic / English numbers and reverse - source

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

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

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

/// verify nationalId with extension methods over [String] class
nationalID = '';
nationalID.isIranianNationalId; // false
  • Find city and province name by national code - source

final place = getPlaceByIranNationalId('0084575948');
place?.city.name; // تهران مرکزی
place?.province.name; // تهران

/// get place with extension methods over [String] class
final nationalId = '2110990147';
nationalId.getPlaceNationalId?.city.name; // گرگان
nationalId.getPlaceNationalId?.province.name; // گلستان
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();
  • Checking IBAN of the bank account (SHEBA) - source

var sheba = Sheba('IR820540102680020817909002');
var bank = sheba(); // Returns nullable object of BankInformation
bank?.nickname // nickname of bank
bank?.name // complete name of bank
bank?.persianName // complete persian name of bank
bank?.code // code of bank
// true means with sheba package can take account number, false means package can't
bank?.isAccountNumberAvailable
bank?.accountNumber // account number in simple numbers
bank?.formattedAccountNumber // account number with hyphen
bank?.process
sheba.isValid // true
  • Validating ATM card number - source

validateCardNumber('6219861034529007'); // true
validateCardNumber('6219861034529007'); // true
validateCardNumber('0000000000000000'); // false
validateCardNumber('621986103452900'); // false
  • Validating Iranians phone number - source

final phoneNumber = '09022002580';

// phone number validator
phoneNumberValidator(phoneNumber); // true

// phone number prefix
getPhonePrefix(phoneNumber); // 902

// phone number detail
final operatorDetail = getPhoneNumberDetail(phoneNumber);
operatorDetail?.name; // ایرانسل
operatorDetail?.provinces; // []
operatorDetail?.base; // کشوری
operatorDetail?.type; // SimCartType.both

/// you can also use this methods as String extension method

// phone number validator
phoneNumber.isPhoneNumber; // true

// phone number prefix
phoneNumber.phoneNumberPrefix; // 902

// phone number detail
phoneNumber.phoneNumberDetail?.name; // ایرانسل
  • Finding banks name by card number - source

final cardNumber = '6037701689095443';

final bankInfo = getBankNameFromCardNumber(cardNumber);
bankInfo?.name; // بانک کشاورزی
bankInfo?.initCode; // 603770

/// you can also use this methods as String extension method

// get bank info from String 
cardNumber.bankNameFromCard?.name; // بانک کشاورزی
  • Fixing and decoding URLs - source

var url = 'wss://hostname.domain/?q=i am a wrong query';
urlFix(url); // wss://hostname.domain/?q=i%20am%20a%20wrong%20query
Comments
  • not Support 0900 & 0996    BUG

    not Support 0900 & 0996 BUG

    سلام این دو شماره موبایل رو که من بهش برخوردم رو ساپورت نمیکنه 0900 0996 و علاوه بر اون اپراتورهای جدید مثل آپتل و سامانتل هم هستند که پشتیبانی نمیشومد!

    opened by akbarrahmani 9
  • Refactor Package & make it more consistent.

    Refactor Package & make it more consistent.

    Since all the features of the package are now available, I think we need a refactoring to make everything more consistent. We should word on following tasks:

    1. core feature dart file should have the name of the feature.
    • if the name of the feature is commas the file name should have a name of commas.dart.
    1. all the models classes should implement in the model.dart file.
    2. all the constant for the specific feature should move to lib/src/constants/feature_name/constants.dart file.
    3. Values that are not used as public APIs must be converted to private access.
    refactor 
    opened by payam-zahedi 9
  • Update/NumberToWords

    Update/NumberToWords

    • Updated NumberToWords algorithm
    • Added test cases
    • Removed method and extension for String type numbers to focus the feature on safe integer values, removed related examples and test cases
    • Added doc for methods and updated README.md
    enhancement feature refactor 
    opened by makhosravi 5
  • words to number completed

    words to number completed

    Words to number feature completed. Note: the fuzzy option not implemented yet

    the example would be something like this:

    final words = 'سه هزار دویست و دوازده';
    
    /// use [wordsToNumber] method to convert [words] to int number
    wordsToNumber(words); // 3212
    
    /// use [wordsToNumberString] method to convert [words] to String
    wordsToNumberString(words); // '3212' as String
    
    /// [wordsToNumberString] also has two optional parameter
    /// use [digit] optional parameter to convert the digits to specific local digits
    /// use [addComma] to add comma between the every 3 digits
    wordsToNumberString(
    words,
    digits: DigitLocale.fa,
    addComma: true,
    ); // '۳,۲۱۲' as String
    
    /// or you can easily use extension methods on String object
    words.convertWordsToNumber(); // 3212
    
    words.convertWordsToNumberString(); // '3212' as String
    
    opened by payam-zahedi 5
  • chore(deps): update actions/checkout action to v3

    chore(deps): update actions/checkout action to v3

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | actions/checkout | action | major | v2 -> v3 |


    Release Notes

    actions/checkout

    v3

    Compare Source


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 3
  • Refactored package

    Refactored package

    The core feature dart file has the name of the feature. All model classes are in the model.dart file. Constants moved to the lib/src/constants/feature_name/constants.dart file. Values that are not used as public APIs were converted to private access.

    opened by makhosravi 3
  • Feature/number to words

    Feature/number to words

    Number to words feature completed. Digits as string or int objects will be converted to Persian words.

    The examples are as follow:

      final stringDigit = '257,433';
      final intDigit = -128;
    
      /// use [numberToWordsString] method to convert [stringDigit] to persian
      print(numberToWordsString(stringDigit)); // 'دویست و پنجاه و هفت هزار و چهارصد و سی و سه'
    
      /// [numberToWordsString] also has an optional parameter
      /// by default [ordinal] is [false], [true] makes the output an ordinal word
      print(numberToWordsString(stringDigit, ordinal: true)); // 'دویست و پنجاه و هفت هزار و چهارصد و سی و سوم'
    
      /// use [numberToWordsInt] method to convert [intDigit] to persian
      print(numberToWordsInt(intDigit)); // 'منفی صد و بیست و هشت'
    
      /// [numberToWordsInt] also has an optional parameter
      /// by default [ordinal] is [false], [true] makes the output an ordinal word
      print(numberToWordsInt(intDigit, ordinal: true)); // 'منفی صد و بیست و هشتم'
    
      /// you can simply use extension methods on int or String objects
      print(stringDigit.convertNumToWordsString()); // 'دویست و پنجاه و هفت هزار و چهارصد و سی و سه'
    
      print(intDigit.convertNumToWordsInt()); // 'منفی صد و بیست و هشت'
    
    feature 
    opened by makhosravi 2
  • Feature/vehicle plate

    Feature/vehicle plate

    simple usage with creating a class for plate information

    var motorcyclePlate = Plate(plate: '12345678');
    motorcyclePlate.info.type // Motorcycle
    motorcyclePlate.info.template // 123-45678
    motorcyclePlate.info.province // مرکز تهران
    motorcyclePlate.info.category // null because its type is Motorcycle
    motorcyclePlate.isValid // true
    
    // because of persian language you may see plate in wrong form
    var carPlate = Plate(plate: '12ب14547');
    carPlate.info.type // Car
    carPlate.info.template // 12{B}145{Iran}47 , B=ب  Iran=ایران
    carPlate.info.province // مرکزی
    carPlate.info.category // شخصی
    carPlate.isValid // true
    

    @ali-master still, my commit messages are wrong or better than previous ones?

    feature 
    opened by EhsanAramide 2
  • Configure Renovate

    Configure Renovate

    Mend Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • .github/workflows/test.yml (github-actions)
    • pubspec.yaml (pub)

    Configuration

    🔡 Renovate has detected a custom config for this PR. Feel free to ask for help if you have any doubts and would like it reviewed.

    Important: Now that this branch is edited, Renovate can't rebase it from the base branch any more. If you make changes to the base branch that could impact this onboarding PR, please merge them manually.

    What to Expect

    With your current configuration, Renovate will create 2 Pull Requests:

    chore(deps): update actions/checkout action to v3
    • Schedule: ["at any time"]
    • Branch name: renovate/actions-checkout-3.x
    • Merge into: master
    • Upgrade actions/checkout to v3
    chore(deps): update codecov/codecov-action action to v3
    • Schedule: ["at any time"]
    • Branch name: renovate/codecov-codecov-action-3.x
    • Merge into: master
    • Upgrade codecov/codecov-action to v3

    ❓ Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 1
  • CONTRIBUTING.md file created

    CONTRIBUTING.md file created

    @ali-master @EhsanAramide Hi there I created the CONTRIBUTING.md file. Please check it out and let me know if any changes needed. Fixing https://github.com/persian-tools/dart-persian-tools/issues/13

    opened by payam-zahedi 1
  • Feature/bank name from card number

    Feature/bank name from card number

    This feature help us find information about the bank from an ATM card number(String).

    The example of this method would be something like this:

    final cardNumber = '6037701689095443';
    
    final bankInfo = getBankNameFromCardNumber(cardNumber);
    bankInfo?.name; // بانک کشاورزی
    bankInfo?.initCode; // 603770
    
    /// you can also use this methods as String extension method
    
    // get bank info from String 
    cardNumber.bankNameFromCard?.name; // بانک کشاورزی
    
    feature 
    opened by payam-zahedi 1
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    Open

    These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

    Detected dependencies

    github-actions
    .github/workflows/test.yml
    • actions/checkout v3
    • dart-lang/setup-dart v1
    • codecov/codecov-action v1
    pub
    pubspec.yaml
    • pedantic ^1.9.0
    • test ^1.14.4

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    opened by renovate[bot] 0
  • chore(deps): update codecov/codecov-action action to v3

    chore(deps): update codecov/codecov-action action to v3

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | codecov/codecov-action | action | major | v1 -> v3 |


    Release Notes

    codecov/codecov-action

    v3

    Compare Source

    v2

    Compare Source


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 2
  • تغییرات اعمالی در نسخه‌ی جدید

    تغییرات اعمالی در نسخه‌ی جدید

    تغییراتی که باید در نسخه‌ی جدید پکیج دارت اعمال بشه نکته: تغییرات باید بر مبنای این پول ریکوئست اعمال بشه

    • [ ] تغییرات وارد شده به ماژول number to word
    • [ ] تغییرات وارد شده به ماژول number plate
    • [ ] تعییرات وارد شده به ماژول phone number
    • [ ] افزودن ماژول time ago
    • [ ] تغییرات وارد شده به ماژول word to number

    نکته: طبق فایل مشارکت‌کنندگان بعد از اتمام هر ویژگی و تغییرات باید مستنداتش کامل باشه بدون کمی کاستی و همچنین تست‌کیس‌های اعمال شده در پول ریکوئست نیز باید در پکیج دارت وارد بشه نکته: تمام بحث‌های مرتبط با بروزرسانی و تقسیم کارها در همین ایژو انجام میشه

    enhancement feature 
    opened by EhsanAramide 3
Owner
Persian Tools
PersianTools.js is a standalone, library-agnostic JavaScript that enables some of the Persian features for use in the JavaScript.
Persian Tools
A few handy Flutter tools, dead simple `UriRouter` for `Uri`-based navigator or `BuildTracker` to track widget rebuilds and what caused them to rebuild.

noob A few handy tools for Flutter apps. UriRouter Hooks Providers PointerIndicator BuildTracker PeriodicListenable UriRouter Dead simple Uri-based pa

null 6 Jan 18, 2022
A tool to easily install the Android SDK command-line and platform tools.

gibadb A tool to easily install the Android SDK command-line and platform tools. For developers: This README describes the CLI tool that ships with th

null 3 Sep 22, 2022
Doing cool stuff with Git VCS in dart programming language.

Git Assistant Assists you to use git and .git in easy and simple way with robust API Features Generates git commands in simple form Supports commands,

Ehsan Aramide 10 Mar 4, 2022
Volt is a wrapper over the Revolt API for easily writing bots using the Dart language.

Volt is a wrapper over the Revolt API for easily writing bots using the Dart language. It is currently in active development so not all of the functionality has yet been implemented.

null 8 Dec 13, 2022
Flutter Version Management: A simple CLI to manage Flutter SDK versions.

fvm Flutter Version Management: A simple cli to manage Flutter SDK versions. FVM helps with the need for a consistent app builds by allowing to refere

Leo Farias 3.2k Jan 8, 2023
Command-line tool to provide null-safety percentage info of a project. Track your migration progress on mixed-version programs that execute with unsound null safety.

null_safety_percentage Command-line tool to provide null-safety percentage info of a project. Track your migration progress on mixed-version programs

dartside.dev 8 Mar 27, 2022
A Dart build script that downloads the Protobuf compiler and Dart plugin to streamline .proto to .dart compilation.

A Dart build script that downloads the Protobuf compiler and Dart plugin to streamline .proto to .dart compilation.

Julien Scholz 10 Oct 26, 2022
Dart wrapper via dart:ffi for https://github.com/libusb/libusb

libusb Dart wrapper via dart:ffi for https://github.com/libusb/libusb Environment Windows(10) macOS Linux(Ubuntu 18.04 LTS) Usage Checkout example Fea

Woodemi Co., Ltd 28 Dec 20, 2022
Extensible Dart interpreter for Dart with full interop

dart_eval is an extensible interpreter for the Dart language, written in Dart. It's powered under the hood by the Dart analyzer, so it achieves 100% c

Ethan 169 Dec 28, 2022
Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.

Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.

Google 905 Jan 2, 2023
AOP for Flutter(Dart)

AspectD Salute to AspectJ. AspectD is an AOP(aspect oriented programming) framework for dart. Like other traditional aop framework, AspectD provides c

null 1k Jan 7, 2023
Environment specific config generator for Dart and Flutter applications during CI/CD builds

Environment Config Generator Environment specific config generator. Allows to specify env configuration during CI/CD build. Primarily created to simpl

Denis Beketsky 86 Dec 2, 2022
A Very Good Command Line Interface for Dart created by Very Good Ventures 🦄

Very Good CLI Developed with ?? by Very Good Ventures ?? A Very Good Command Line Interface for Dart. Installing $ dart pub global activate very_good_

Very Good Open Source 1.8k Jan 8, 2023
🚀The Flutter dart code generator from zeplin. ex) Container, Text, Color, TextStyle, ... - Save your time.

Flutter Gen Zeplin Extension ?? The Flutter dart code generator from zeplin. ex) Container, Text, Color, TextStyle, ... - Save your time. ⬇ 1.1k Getti

NAVER 49 Oct 12, 2022
A Dart package to web scraping data from websites easily and faster using less code lines.

Chaleno A flutter package to webscraping data from websites This package contains a set of high-level functions that make it easy to webscrap websites

António Nicolau 30 Dec 29, 2022
A pure dart package to apply useful rate limiting strategies on regular functions.

Rate limiting is a strategy for limiting an action. It puts a cap on how often someone can repeat an action within a certain timeframe. Using rate_limiter we made it easier than ever to apply these strategies on regular dart functions.

Stream 24 Dec 14, 2022
Dart phone number parser, based on libphonenumber and PhoneNumberKit.

Dart library for parsing phone numbers. Inspired by Google's libphonenumber and PhoneNumberKit for ios.

cedvdb 39 Dec 31, 2022
Basic Dart reverse shell code

dart_rs Basic Dart reverse shell based on this one by Potato-Industries. Pretty self explanatory. You’ll need Windows. I used a Windows 7 64-bit VM. F

null 21 Oct 2, 2022
Dart phone number parser, based on libphonenumber and PhoneNumberKit.

Phone Numbers Parser Dart library for parsing phone numbers. Inspired by Google's libphonenumber and PhoneNumberKit for ios. The advantage of this lib

cedvdb 39 Dec 31, 2022