Skip to content

Commit 4e29079

Browse files
author
Saligzhanov Ilya
committed
feat: repository moved from GitLab to GitHub
1 parent fabc211 commit 4e29079

24 files changed

+5210
-2
lines changed

.gitattributes

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.gitlab/ export-ignore
2+
tests/ export-ignore
3+
.gitignore export-ignore
4+
.gitattributes export-ignore
5+
.php-cs-fixer.dist.php export-ignore
6+
phpstan.neon export-ignore
7+
phpunit.xml export-ignore

.github/pull_request_template.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!-- Развёрнутое описание изменений на русском -->
2+
3+
## Чек-лист
4+
5+
- [ ] Я **самостоятельно** проверил код моих изменений **перед** тем, как отдать его на code-review
6+
- [ ] Я подтянул `main`-ветку
7+
- [ ] Заголовок MR-а соответствует сути задачи и написан в формате [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
/vendor/
3+
*.cache

.php-cs-fixer.dist.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(__DIR__ . '/')
5+
->in(__DIR__ . '/src')
6+
->append(['.php_cs']);
7+
8+
$rules = [
9+
'@PSR12' => true,
10+
'array_syntax' => ['syntax' => 'short'],
11+
'blank_line_before_statement' => true,
12+
];
13+
14+
$rules['increment_style'] = ['style' => 'post'];
15+
16+
return (new PhpCsFixer\Config())
17+
->setUsingCache(false)
18+
->setRules($rules)
19+
->setFinder($finder);

ASSURANCE.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Honesty assurance
2+
3+
1. [ru_RU Русский](#Клятва чести)
4+
2. [en_EN English](#Oath of honor)
5+
6+
## Клятва чести
7+
8+
Я, `LeTraceurSnork`, торжественно клянусь, что этот и все мои другие OpenSource проекты я не закрою, не подвергну
9+
сознательным вредоносным изменениям, не ограничу доступ, не буду использовать пакет в политических, культурных и любых
10+
других, не связанных с назначением проекта, целях и буду по мере сил и возможностей способствовать его продвижению и
11+
общедоступности*. Нарушение мной клятвы по любым, особенно политическим причинам, даёт право обнаружившему нарушение
12+
называть меня маленькой сопливой девочкой, пуськой и другими обидными прозвищами, а также отказаться от использования
13+
всех моих пакетов. Удаление данного файла из репозитория приравнивается к нарушению клятвы.
14+
15+
*- Кроме случаев, когда это противоречит законодательству страны, контролирующей территорию распространения, или
16+
предоставляющей гражданство получателю.
17+
18+
## Oath of honor
19+
20+
I, `LeTraceurSnork`, do solemnly swear that this and all my other OpenSource projects I will not shut down, subject to
21+
deliberately harmful changes, restrict access to, or use the package for political, cultural, or any other purposes that
22+
is unrelated to the project designation, and I will, to the best of my ability, contribute to its promotion and public
23+
access*. Violation of my oath for any, especially political reasons, entitles the person who discovered the violation to
24+
call me a snotty little girl and other offensive nicknames, and also refuse to use all my packages. Removing
25+
this file from the repository is tantamount to breaking an oath.
26+
27+
*- Except when it is contrary to the laws of the country that controls the territory of distribution, or grants
28+
citizenship to the recipient.

CHANGELOG.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver].
6+
7+
---
8+
9+
## [v1.0.0](https://gitlab.com/LeTraceurSnork/russian-validators/-/compare/905c00d52eb9a65b5af902bef6ccdbaf7224a24c...v1.0.0)
10+
11+
### Added
12+
13+
- INN, KPP, OGRN/OGRNIP and SNILS validators and its tests
14+
- AbstractValidator class and its Interface to grant an ability to extend the functionality
15+
16+
[keepachangelog]:https://keepachangelog.com/en/1.0.0/
17+
18+
[semver]:https://semver.org/spec/v2.0.0.html
19+
20+
[@saligzhanov.i]:https://gitlab.spectrumdata.tech/saligzhanov.i

README.md

+47-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,47 @@
1-
# russian-validators
2-
Валидаторы российских идентификаторов
1+
# Russian Validators
2+
3+
## Описание
4+
5+
Пакет предназначен для валидации различных идентификаторов, принятых в РФ - СНИЛС, ИНН, ОГРН/ОГРНИП и КПП, поскольку
6+
"международные" валидаторы (напр., из пакета Symfony) не учитывают их отдельно от VAT и прочих международных
7+
аналогов
8+
9+
В описании каждого класса валидатора приведена ссылка на Википедию и, по возможности, на соответствующий закон
10+
Правительства, поясняющий, почему тот или иной идентификатор валидируется именно так
11+
12+
## Установка с помощью composer
13+
14+
```
15+
composer install letraceursnork/russian-validators
16+
```
17+
18+
## Требования
19+
20+
Пакет требует всего двух пунктов:
21+
22+
1. PHP 8.0+
23+
2. Установленную и подключенную библиотеку `BCMath` (`ext-bcmath`)
24+
25+
## Пример использования
26+
27+
```php
28+
use LTS\RussianValidators\InnValidator;
29+
//use LTS\RussianValidators\KppValidator;
30+
//use LTS\RussianValidators\OgrnipValidator;
31+
//use LTS\RussianValidators\OgrnValidator;
32+
//use LTS\RussianValidators\SnilsValidator;
33+
34+
$value = '<SOME_INN>';
35+
$validator = new InnValidator(); // или любой другой класс валидатора из перечисленных выше
36+
37+
$validator->setPurifyPattern('[-+\/\*\\_\.,\s]'); // установить $pattern для функции preg_replace. Все символы, попадающие под $pattern будут удалены из строки перед валидацией. Позволяет очистить строку от разделителей - $pattern по-умолчанию `[-+\/\*\\_\.,\s]`
38+
39+
$is_valid = $validator->validate($value); // true|false
40+
41+
$validator->throwErrorOnInvalid(); // При неудачной валидации не возвращает false, а выбрасывает исключение типа InvalidArgumentException
42+
try {
43+
$is_valid = $validator->validate($value); // true, если валидация успешна
44+
} catch(InvalidArgumentException $exception) {
45+
// Обработка исключения
46+
}
47+
```

composer.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "letraceursnork/russian-validators",
3+
"description": "A package containing various validators of Russian identifiers e.g. INN, SNILS, OGRN etc.",
4+
"type": "library",
5+
"license": "MIT",
6+
"autoload": {
7+
"psr-4": {
8+
"LTS\\RussianValidators\\": "src/",
9+
"LTS\\RussianValidators\\Tests\\": "tests/"
10+
}
11+
},
12+
"authors": [
13+
{
14+
"name": "letraceursnork",
15+
"email": "[email protected]"
16+
}
17+
],
18+
"minimum-stability": "stable",
19+
"require": {
20+
"php": ">=8.0",
21+
"ext-bcmath": "*"
22+
},
23+
"require-dev": {
24+
"phpunit/phpunit": "^9.5",
25+
"phpstan/phpstan": "^1.9",
26+
"friendsofphp/php-cs-fixer": "^3.13"
27+
},
28+
"scripts": {
29+
"phpunit": "@php ./vendor/bin/phpunit ./tests --configuration phpunit.xml --no-coverage --color=always",
30+
"phpstan": "@php ./vendor/bin/phpstan analyze -c ./phpstan.neon --no-progress --ansi --verbose",
31+
"php-cs-fixer-fix": "@php ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php"
32+
}
33+
}

0 commit comments

Comments
 (0)