Skip to content

Commit

Permalink
v1.6.0 Release (#7)
Browse files Browse the repository at this point in the history
* v1.6.0 [WIP][feature]: Implements validation

* 1.6.0 [feature] Add TimeZone, Time, Date, DatTime validation

* 1.6.0 [feature] Add Negative, Negative_or_Zero, Positive, Positive_or_Zero validators

* v1.6.0 [downgrade] switch to php8.1 version

* v1.6.0 [feature] Implements validators: EqualTo, NotEqualTo, GreaterThan, GreaterThanOrEqual,LessThan, LessThanOrEqual, Identical, NotIdentical, Range

* v1.6.0 [feature] Implements validators: CardScheme

* v1.6.0 [fix] delete debug information

* v1.6.0 [compatibility] allow ^5|^6 validators

* v1.6.0 [feature] Implements BIC validation

* v1.6.0 [feature] Implements Currency validation

* v1.6.0 [feature] Implements Luhn algorithm validation

* v1.6.0 [feature] Implements Iban validation

* v1.6.0 [feature] Implements Isbn validation

* v1.6.0 [feature] Implements Issn validation

* v1.6.0 [feature] Implements Isin validation

* v1.6.0 [improvements] Implements psalm, phpstan, phpunit
  • Loading branch information
Asisyas authored Feb 15, 2023
1 parent cfe87c8 commit fc14ffc
Show file tree
Hide file tree
Showing 133 changed files with 5,779 additions and 843 deletions.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/.github export-ignore
/tests export-ignore
/phpunit.xml.dist export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php-cs-fixer.dist.php export-ignore
/psalm.xml export-ignore

*.php diff=php
12 changes: 9 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
out/
vendor/
.idea
vendor
composer.lock
.phpunit.result.cache
.phpunit.result.cache
.php-cs-fixer.cache
test-coverage-report
phpunit.xml
coverage/
.php-cs-fixer.php
phpstan.neon
67 changes: 67 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

if (!file_exists(__DIR__.'/src')) {
exit(0);
}

$finder = (new PhpCsFixer\Finder())
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
;

return (new PhpCsFixer\Config())
->setRules(array(
'@Symfony' => true,
'@Symfony:risky' => true,
'protected_to_private' => false,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'declare_strict_types' => true,
'dir_constant' => true,
'fully_qualified_strict_types' => true,
'linebreak_after_opening_tag' => true,
'mb_str_functions' => true,
'modernize_types_casting' => true,
'no_alternative_syntax' => true,
'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'no_superfluous_elseif' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
'phpdoc_to_comment' => false,
'phpdoc_types_order' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'none'
],
'php_unit_set_up_tear_down_visibility' => true,
'pow_to_exponentiation' => true,
'semicolon_after_instruction' => true,
'ternary_to_null_coalescing' => true,
'method_argument_space' => [
'keep_multiple_spaces_after_comma' => true,
'on_multiline' => 'ensure_fully_multiline',
'after_heredoc' => true,
],
'phpdoc_annotation_without_dot' => false,
'phpdoc_var_without_name' => false,
'phpdoc_trim' => true,
'no_superfluous_phpdoc_tags' => false,
'single_line_throw' => true,
'header_comment' => [
'header' => <<<EOF
This file is part of the Micro framework package.
(c) Stanislau Komar <[email protected]>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF
]
))
->setRiskyAllowed(true)
->setFinder($finder);
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Komar Stanislau

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
83 changes: 64 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,79 @@
{
"name": "micro/dto",
"description": "Micro: Library for generating DTO classes.",
"keywords": ["dto", "data transfer", "transfer", "data", "object", "generator", "data transfer object", "micro"],
"type": "library",
"description": "Library for generating and validation DTO classes.",
"license": "MIT",
"version": "1.0.6",
"type": "library",
"keywords": [
"dto",
"data transfer",
"transfer",
"data",
"object",
"generator",
"data transfer object",
"micro"
],
"authors": [
{
"name": "Stanislau Komar",
"email": "[email protected]"
}
],
"require": {
"php": ">= 8.1",
"ext-dom": "*",
"ext-intl": "*",
"ext-libxml": "*",
"nette/php-generator": "^4",
"psr/log": "^1 || ^2 || ^3",
"symfony/intl": "^5 || ^6",
"symfony/property-access": "^5 || ^6",
"symfony/validator": "^5 || ^6"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.29",
"friendsofphp/php-cs-fixer": "^3.13",
"phpstan/phpstan": "^1.9",
"phpunit/php-code-coverage": "^9.2",
"phpunit/phpunit": "^9.5",
"symfony/var-dumper": "^5 || ^6",
"vimeo/psalm": "^5.2"
},
"autoload": {
"psr-4": {
"Micro\\Library\\DTO\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Micro\\Library\\DTO\\Tests\\": "tests/",
"TransferTest\\": "tests/DTO/"
"TransferTest\\": "tests/DTO/",
"Micro\\Library\\DTO\\Tests\\": "tests/"
}
},
"authors": [
{
"name": "Stanislau Komar",
"email": "[email protected]"
}
],
"require": {
"php": ">= 8.0",
"nette/php-generator": "^3|^4",
"psr/log": "^1|^2|^3"
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true
},
"sort-packages": true
},
"require-dev": {
"symfony/var-dumper": "^5|^6",
"phpunit/phpunit": "^9"
"scripts": {
"coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-text",
"coverage-html": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html ./test-coverage-report",
"php-cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 ./vendor/bin/php-cs-fixer fix --verbose --using-cache=no",
"php-cs-try": "PHP_CS_FIXER_IGNORE_ENV=1 ./vendor/bin/php-cs-fixer fix --verbose --dry-run --using-cache=no",
"phpstan": "./vendor/bin/phpstan analyze --no-progress",
"phpunit": "./vendor/bin/phpunit",
"psalm": "./vendor/bin/psalm --no-progress --show-info=true --no-cache",
"statics": [
"@phpstan",
"@psalm",
"@php-cs-try"
],
"test": [
"@statics",
"composer validate --strict",
"composer normalize",
"@coverage"
]
}
}
127 changes: 123 additions & 4 deletions example/example.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,139 @@
<?xml version="1.0"?>
<dto xmlns="micro:dto-01"
<dto xmlns="micro:dto-1.6"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="micro:dto-01 ../src/Resource/schema/dto-01.xsd">
xsi:schemaLocation="micro:dto-1.6 ../src/Resource/schema/dto-1.6.xsd">

<class name="Simple\SimpleObject">
<property name="weight" type="int"/>
<property name="weight" type="int">
<validation>
<less_than value="10" />
</validation>
</property>
</class>

<class name="Simple\SimpleObject">
<property name="height" type="int"/>
<property name="height" type="int">
<validation>
<less_than property_path="weight"/>
</validation>
</property>
</class>
<class name="Simple\SimpleObject">
<property name="parent" type="Simple\SimpleObject"/>
</class>

<class name="Simple\SimpleUser">
<property name="parent" type="Simple\SimpleObject"/>
<property name="username" type="string">
<validation>
<length min="6" max="50"/>
<regex pattern="/^(.[aA-zA]+)$/"/>
</validation>
</property>
<property name="age" type="int">
<validation>
<not_blank />
<greater_than value="18" />
<less_than value="100" />
</validation>
</property>
<property name="email" type="string">
<validation>
<email/>
<not_blank/>
</validation>
</property>
<property name="ip" type="string">
<validation>
<ip/>
</validation>
</property>
<property name="hostname" type="string">
<validation>
<hostname />
<hostname ltd_required="true" groups="test"/>
</validation>
</property>
<property name="sometext" type="string">
<validation>
<regex pattern="/^(.[a-z])+$/"/>
</validation>
</property>
<property name="url" type="string">
<validation>
<url is_relative="true" />
</validation>
</property>
<property name="json" type="string">
<validation>
<not_blank/>
<json/>
</validation>
</property>
<property name="uuid" type="string">
<validation>
<not_blank />
<uuid />
</validation>
</property>
<property name="created_at" type="string">
<validation>
<datetime />
</validation>
</property>
<property name="updated_at" type="string">
<validation>
<date />
</validation>
</property>
<property name="timezone" type="string">
<validation>
<time_zone intl_compatible="true" country_code="BY" zone="4096"/>
</validation>
</property>
<property name="card_scheme" type="string">
<validation>
<not_blank />
<card_scheme schemes="MASTERCARD"/>
<luhn />
</validation>
</property>
<property name="bic" type="string">
<validation>
<not_blank />
<bic />
</validation>
</property>
<property name="currency" type="string">
<validation>
<not_blank />
<currency />
</validation>
</property>
<property name="iban" type="string">
<validation>
<not_blank />
<iban />
</validation>
</property>
<property name="isbn" type="string">
<validation>
<not_blank />
<isbn type="isbn13" />
</validation>
</property>
<property name="issn" type="string">
<validation>
<not_blank />
<issn />
</validation>
</property>
<property name="isin" type="string">
<validation>
<not_blank />
<isin />
</validation>
</property>
</class>

<class name="User" description="Example class description" deprecated="Please, use gSON">
Expand Down
Loading

0 comments on commit fc14ffc

Please sign in to comment.