Skip to content

Commit 7b12e57

Browse files
github-actions[bot]romaninshDarkSide666web-flow
authored
Releasing 0.4 into master (#3)
* Update README.md * merge into develop * Apply fixes from StyleCI * should be master * min php 7.0 * adds support for custom error messages * update readme * fix rule merging * refactor validator again * Apply fixes from StyleCI * Update composer.json * be careful * Apply fixes from StyleCI * update * Create unit-tests.yml * Create bundler.yml * Create release-drafter.yml * draft * Setting release dependencies Co-authored-by: Romans Malinovskis <me@nearly.guru> Co-authored-by: Imants Horsts <DarkSide666@users.noreply.github.com> Co-authored-by: GitHub Web Flow <noreply@github.com>
1 parent 5d3571f commit 7b12e57

File tree

12 files changed

+272
-99
lines changed

12 files changed

+272
-99
lines changed

.github/release-drafter.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# See https://github.com/release-drafter/release-drafter#configuration
2+
template: |
3+
## What’s Changed
4+
5+
$CHANGES

.github/workflows/bundler.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Bundler
2+
3+
on: create
4+
5+
jobs:
6+
autocommit:
7+
name: Update to stable dependencies
8+
if: startsWith(github.ref, 'refs/heads/release/')
9+
runs-on: ubuntu-latest
10+
container:
11+
image: atk4/image:latest # https://github.com/atk4/image
12+
steps:
13+
- uses: actions/checkout@master
14+
- run: echo ${{ github.ref }}
15+
- name: Update to stable dependencies
16+
run: |
17+
# replaces X keys with X-release keys
18+
jq '. as $in | reduce (keys_unsorted[] | select(endswith("-release")|not)) as $k ({}; . + {($k) : (($k + "-release") as $kr | $in | if has($kr) then .[$kr] else .[$k] end) } )' < composer.json > tmp && mv tmp composer.json
19+
v=$(echo ${{ github.ref }} | cut -d / -f 4)
20+
echo "::set-env name=version::$v"
21+
22+
- uses: teaminkling/autocommit@master
23+
with:
24+
commit-message: Setting release dependencies
25+
- uses: ad-m/github-push-action@master
26+
with:
27+
branch: ${{ github.ref }}
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: pull-request
31+
uses: romaninsh/pull-request@master
32+
with:
33+
source_branch: "release/${{ env.version }}"
34+
destination_branch: "master" # If blank, default: master
35+
pr_title: "Releasing ${{ env.version }} into master"
36+
pr_body: |
37+
- [ ] Review changes (must include stable dependencies)
38+
- [ ] Merge this PR into master (will delete ${{ github.ref }})
39+
- [ ] Go to Releases and create TAG from master
40+
Do not merge master into develop
41+
pr_reviewer: "romaninsh"
42+
pr_assignee: "romaninsh"
43+
github_token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
# branches to consider in the event; optional, defaults to all
6+
branches:
7+
- develop
8+
9+
jobs:
10+
update_release_draft:
11+
runs-on: ubuntu-latest
12+
steps:
13+
# Drafts your next Release notes as Pull Requests are merged into "master"
14+
- uses: toolmantim/release-drafter@master
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/unit-tests.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Unit Testing
2+
3+
on:
4+
pull_request:
5+
branches: '*'
6+
push:
7+
branches:
8+
- master
9+
- develop
10+
11+
jobs:
12+
unit-test:
13+
name: Unit Testing
14+
runs-on: ubuntu-latest
15+
container:
16+
image: atk4/image:${{ matrix.php }} # https://github.com/atk4/image
17+
strategy:
18+
matrix:
19+
php: ['7.2', '7.3', 'latest']
20+
steps:
21+
- uses: actions/checkout@v1
22+
# need this to trick composer
23+
- run: php --version
24+
- run: "git branch develop; git checkout develop"
25+
- name: Get Composer Cache Directory
26+
id: composer-cache
27+
run: |
28+
echo "::set-output name=dir::$(composer config cache-files-dir)"
29+
30+
- uses: actions/cache@v1
31+
with:
32+
path: ${{ steps.composer-cache.outputs.dir }}
33+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
34+
restore-keys: |
35+
${{ runner.os }}-composer-
36+
37+
- run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
38+
39+
- name: Run Tests
40+
run: |
41+
mkdir -p build/logs
42+
43+
- name: SQLite Testing
44+
run: vendor/bin/phpunit --configuration phpunit.xml --coverage-text
45+
46+
- uses: codecov/codecov-action@v1
47+
if: matrix.php == 'latest'
48+
with:
49+
token: ${{ secrets.CODECOV_TOKEN }}
50+
file: build/logs/clover.xml

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
language: php
22

33
php:
4-
- '5.6'
5-
- '7.0'
6-
- '7.1'
74
- '7.2'
85
- '7.3'
96

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This is validator add-on for Agile Data (https://github.com/atk4/data).
55
It uses https://github.com/vlucas/valitron under the hood.
66

77

8-
[![Build Status](https://travis-ci.org/atk4/validate.png?branch=master)](https://travis-ci.org/atk4/validate)
8+
[![Build Status](https://travis-ci.org/atk4/validate.png?branch=develop)](https://travis-ci.org/atk4/validate)
99
[![Code Climate](https://codeclimate.com/github/atk4/validate/badges/gpa.svg)](https://codeclimate.com/github/atk4/validate)
1010
[![StyleCI](https://styleci.io/repos/161695320/shield)](https://styleci.io/repos/161695320)
1111
[![CodeCov](https://codecov.io/gh/atk4/validate/branch/develop/graph/badge.svg)](https://codecov.io/gh/atk4/validate)
@@ -31,14 +31,14 @@ $v = new \atk4\validate\Validator($model);
3131

3232
// set simple validation rule for one field
3333
// ->rule($field, $rules)
34-
$v->rule('name', ['required','lengthMin'=>3]);
34+
$v->rule('name', [ 'required', ['lengthMin', 3] ]);
3535

3636
// set multiple validation rules in one shot
3737
// ->rules($array_of_rules) // [field=>rules]
3838
$v->rules([
39-
'name' => ['required', 'lengthMin'=>3],
40-
'age' => ['integer', 'min'=>0, 'max'=>99],
41-
'tail_length' => ['integer', 'min'=>0],
39+
'name' => ['required', ['lengthMin',3]],
40+
'age' => ['integer', ['min',0], ['max',99]],
41+
'tail_length' => ['integer', ['min',0]],
4242
]);
4343

4444
// set validation rules based on value of another field
@@ -48,13 +48,18 @@ $v->if(['type'=>'dog'], [
4848
'age' => ['required'],
4949
'tail_length' => ['required'],
5050
], [
51-
'tail_length' => ['equals'=>''], // balls don't have tail
51+
'tail_length' => [ ['equals',''] ], // balls don't have tail
5252
]);
5353

5454
// you can also pass multiple conditions which will be treated as AND conditions
5555
$v->if(['type'=>'dog', 'age'=>50], $rules_if_true, $rules_if_false);
56+
57+
// you can also set custom error message like this:
58+
$v->rule('age', [ ['min', 3, 'message'=>'Common! {field} to small'] ]);
59+
// and you will get this "Common! Age to small"
5660
```
5761

5862
You can also pass callback instead of array of rules.
63+
Callback receives these parameters $field, $value, $args, $data and should return true/false.
5964

6065
See `/tests` folder for more examples.

composer.json

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,52 @@
11
{
2-
"name": "atk4/validate",
3-
"type": "library",
4-
"description": "Agile Data - Validator add-on",
5-
"keywords": ["framework", "orm", "query", "active record", "sql", "builder", "nosql", "mongodb", "mysql", "postgresql", "validator", "validate"],
6-
"homepage": "https://github.com/atk4/validate",
7-
"license": "MIT",
8-
"authors": [
9-
{
10-
"name": "Romans Malinovskis",
11-
"email": "romans@agiletoolkit.org",
12-
"homepage": "https://nearly.guru/"
13-
}
14-
],
15-
"minimum-stability": "dev",
16-
"prefer-stable": true,
17-
"require": {
18-
"php": ">=7.0.0",
19-
"atk4/data": "dev-develop",
20-
"vlucas/valitron": "^1.4"
21-
},
22-
"require-dev": {
23-
"atk4/schema": "dev-develop",
24-
"phpunit/phpunit": "<6",
25-
"phpunit/dbunit": ">=1.2",
26-
"phpunit/phpcov": "*",
27-
"codeclimate/php-test-reporter": "*"
28-
},
29-
"autoload": {
30-
"psr-4": {"atk4\\validate\\":"src/"}
31-
},
32-
"autoload-dev": {
33-
"psr-4": {
34-
"atk4\\validate\\tests\\":"tests/"
35-
}
2+
"name": "atk4/validate",
3+
"type": "library",
4+
"description": "Agile Data - Validator add-on",
5+
"keywords": [
6+
"framework",
7+
"orm",
8+
"query",
9+
"active record",
10+
"sql",
11+
"builder",
12+
"nosql",
13+
"mongodb",
14+
"mysql",
15+
"postgresql",
16+
"validator",
17+
"validate"
18+
],
19+
"homepage": "https://github.com/atk4/validate",
20+
"license": "MIT",
21+
"authors": [
22+
{
23+
"name": "Romans Malinovskis",
24+
"email": "romans@agiletoolkit.org",
25+
"homepage": "https://nearly.guru/"
3626
}
27+
],
28+
"minimum-stability": "dev",
29+
"prefer-stable": true,
30+
"require": {
31+
"php": ">=7.2.0",
32+
"atk4/data": "^2.0",
33+
"vlucas/valitron": "^1.4"
34+
},
35+
"require-dev": {
36+
"atk4/schema": "^2.0",
37+
"phpunit/phpunit": "<6",
38+
"phpunit/dbunit": ">=1.2",
39+
"phpunit/phpcov": "*",
40+
"codeclimate/php-test-reporter": "*"
41+
},
42+
"autoload": {
43+
"psr-4": {
44+
"atk4\\validate\\": "src/"
45+
}
46+
},
47+
"autoload-dev": {
48+
"psr-4": {
49+
"atk4\\validate\\tests\\": "tests/"
50+
}
51+
}
3752
}

phpunit-mysql.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<testsuites>
1717
<testsuite name="tests">
1818
<directory>tests</directory>
19-
<exclude>tests/smbo/lib</exclude>
2019
</testsuite>
2120
</testsuites>
2221
<logging>

phpunit-pgsql.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<testsuites>
1717
<testsuite name="tests">
1818
<directory>tests</directory>
19-
<exclude>tests/smbo/lib</exclude>
2019
</testsuite>
2120
</testsuites>
2221
<logging>

phpunit.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<testsuites>
1717
<testsuite name="tests">
1818
<directory>tests</directory>
19-
<exclude>tests/smbo/lib</exclude>
2019
</testsuite>
2120
</testsuites>
2221
<logging>

0 commit comments

Comments
 (0)