Simple gem, that validates document check sum.
gem install dockcheck
or using Gemfile gem 'dockcheck', '~> 2.0'
- INN
- BIK
- KPP
- SNILS
- OGRN
- OGRNIP
For input use Hashmap with following stucture:
type - type of document, required, symbol or stringcontent - document numbers, required, stringextra - extra data of document, optional, string
Output structure contains input data and some additional fields:
error - validation errorcorrect - validation result
checker = DockCheck.new()
checker.check({type: :inn, content: "7743013901"})
{type: :inn, content: "7743013901", correct: true, error: ""}
checker.check({type: :inn, content: "8800555"})
{type: :inn, content: "8800555", correct: false, error: 'Incorrect inn numbers count!'}
checker.check({type: :snils, content: "12345678901"})
{type: :snils, content: "12345678901", correct: false, error: ""}
checker.list_checkers
[:inn, :snils, :bik, :kpp, :ogrnip, :ogrn]
checker.check_many([{type: :inn, content: "7743013901"}, {type: :bik, content: "123456?!@"}])
[{type: :inn, content: "7743013901", correct: true, error: ""}, {type: :bik, content: "123456?!@", correct: false, error: ""}]