https://github.com/solar05/dockcheck
Simple gem, that validates document check sum.
https://github.com/solar05/dockcheck
library ruby validator
Last synced: 24 days ago
JSON representation
Simple gem, that validates document check sum.
- Host: GitHub
- URL: https://github.com/solar05/dockcheck
- Owner: solar05
- License: mit
- Created: 2021-06-13T22:42:32.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-01-02T00:07:09.000Z (over 4 years ago)
- Last Synced: 2025-03-04T08:45:45.927Z (over 1 year ago)
- Topics: library, ruby, validator
- Language: Ruby
- Homepage: https://rubygems.org/gems/dockcheck
- Size: 71.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dockcheck [](https://badge.fury.io/rb/dockcheck) [](https://github.com/solar05/dockcheck/actions/workflows/ruby.yml) [](https://codeclimate.com/github/solar05/dockcheck/maintainability) [](https://codecov.io/gh/solar05/dockcheck)
Simple gem, that validates document check sum.
## Install
`gem install dockcheck`
or using Gemfile `gem 'dockcheck', '~> 2.0'`
### Validators list
- INN
- BIK
- KPP
- SNILS
- OGRN
- OGRNIP
### Validation structure
For input use Hashmap with following stucture:
- `type - type of document, required, symbol or string`
- `content - document numbers, required, string`
- `extra - extra data of document, optional, string`
Output structure contains input data and some additional fields:
- `error - validation error`
- `correct - validation result`
#### Examples
```Ruby
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: ""}]
```