irvalidate
کتابخانهی سبک و بدون وابستگی پایتون برای اعتبارسنجی دادههای ایرانی: کد ملی، شناسه ملی شرکت، شماره کارت، شبا، موبایل و کد پستی.
A tiny, zero-dependency Python library for validating Iranian data: national ID, legal ID, bank card, Sheba (IBAN), mobile number and postal code.
نصب
pip install irvalidate
یا مستقیم از گیتهاب:
pip install git+https://github.com/mehdirzfx/irvalidate.git
نیازمند پایتون ۳.۹ به بالا.
استفاده
from irvalidate import (
is_valid_national_id, is_valid_legal_id, is_valid_card_number,
is_valid_sheba, is_valid_mobile, is_valid_postal_code,
card_bank, sheba_bank, mobile_operator, normalize_mobile,
)
is_valid_national_id("0013542419") # True
is_valid_national_id("۰۰۱۳۵۴۲۴۱۹") # True (ارقام فارسی هم پشتیبانی میشود)
is_valid_legal_id("14003778990") # True (شناسه ملی شرکتها)
is_valid_card_number("6037-9910-0000-0004") # True
card_bank("6037991000000004").name_fa # 'بانک ملی ایران'
is_valid_sheba("IR580540105180021273113007") # True (پیشوند IR اختیاری است)
sheba_bank("IR580540105180021273113007").name_en # 'Parsian Bank'
is_valid_mobile("+98 912 345 6789") # True
normalize_mobile("۰۹۱۲۳۴۵۶۷۸۹") # '09123456789'
normalize_mobile("09123456789", international=True) # '+989123456789'
mobile_operator("09351234567") # 'Irancell'
is_valid_postal_code("1593764856") # True
خط فرمان
irvalidate national-id 0013542419
irvalidate card 6037991000000004
irvalidate sheba IR580540105180021273113007
# انواع: national-id, legal-id, card, sheba, mobile, postal-code
خروجی valid یا invalid است و کد خروج ۰ یا ۱ برمیگردد (مناسب اسکریپتها).
نکات مهم
- ورودی را رشته بدهید، نه عدد. کد ملیهایی که با صفر شروع میشوند در تبدیل به عدد خراب میشوند؛ توابع برای ورودی غیررشتهای
Falseبرمیگردانند. - فاصله، خط تیره، نیمفاصله و پرانتز نادیده گرفته میشوند.
- معتبر بودن ≠ وجود داشتن. این کتابخانه فقط ساختار و رقم کنترلی را بررسی میکند؛ نمیتواند بگوید کارت یا کد ملی واقعاً متعلق به کسی هست یا نه.
- کد پستی فقط از نظر قالب بررسی میشود، نه وجود آدرس.
- لیست بانکها (از روی BIN کارت و کد شبا) و پیششمارهی اپراتورهای موبایل بر پایهی اطلاعات عمومی است و ممکن است ناقص باشد. اگر موردی جا افتاده، PR بدهید (
src/irvalidate/banks.py).
مشارکت
git clone https://github.com/mehdirzfx/irvalidate.git
cd irvalidate
pip install -e ".[dev]"
pytest
Issue و Pull Request خوشحالمان میکند.
مجوز
MIT — آزاد برای استفادهی شخصی و تجاری.
Metadata
Release files for irvalidate 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| irvalidate-0.1.0.tar.gz | 10.3 kB | With provenance | Details for irvalidate-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| irvalidate-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for irvalidate-0.1.0-py3-none-any.whl |
Total release size: 23.0 kB
Release files / irvalidate-0.1.0.tar.gz
| Download URL | irvalidate-0.1.0.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e06f6ff2473cced088a6633d4bee089c64517cb0f8dc3c3c544dbbecb683889
|
|
BLAKE2b-256 checksum How to use checksums |
127b95d742319c093ae7cc6cbc107273860307c304d684cb0495e18c33199a26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / irvalidate-0.1.0-py3-none-any.whl
| Download URL | irvalidate-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9650d9581c660fd26724c3876aa7ae7467a6e57ab3b18c59b05fd30f427ea9c3
|
|
BLAKE2b-256 checksum How to use checksums |
cfc7be7f823f10e243586d4685fee9aef2023a2e7415b59d821f33e3a3ee761c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logSecurity for irvalidate 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for irvalidate-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.