Skip to main content

Django RU validators

Project description

Django russian financial validators

l10n russian validators for INN, bank account number

Build Status

Install

$ pip install django-ru-validators

Usage

from django import forms
from django.db import models
from django.core.exceptions import ValidationError
from django_ru_validators import validate_inn, BankAccountNumberValidator


class PaymentOrder(models.Model):
    recipient_inn = models.CharField(validators=[validate_inn])
    recipient_account_number = models.CharField()
    recipient_bank = models.CharField()


class PaymentOrderForm(forms.ModelForm):
    class Meta:
        model = PaymentOrder
        fields = ("recipient_inn", "recipient_account_number", "recipient_bik")

    def clean(self):
        cleaned_data = super().clean()
        recipient_account_number = cleaned_data.get("recipient_account_number")
        recipient_bik = cleaned_data.get("recipient_bik")
        try:
            BankAccountNumberValidator(recipient_bik)(recipient_account_number)
        except ValidationError:
            msg = "Wrong combination of account number and bik of bank"
            self.add_error("recipient_account_number", msg)
            self.add_error("recipient_bik", msg)

        return cleaned_data

Development

Install dependencies with

$ pip install --requirement requirements.txt

Run tests with

$ python setup.py test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_ru_validators-1.7.0.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file django_ru_validators-1.7.0.tar.gz.

File metadata

  • Download URL: django_ru_validators-1.7.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.1

File hashes

Hashes for django_ru_validators-1.7.0.tar.gz
Algorithm Hash digest
SHA256 95652b3e667564a475dceb0af4f217cf863ede6fd0bdff2d6d5d3bc4960ec95a
MD5 d7ee10981dd2ec5df0f74235c7c423dd
BLAKE2b-256 dffcb4644e9c5b783f0d21feca4cfd29b6bddd9b0a7efe16280a9bb7d3e18396

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page