Skip to content

Commit 3e9742a

Browse files
authored
Merge pull request #12 from anigenero/onblur-fix
fix filter state
2 parents 3ab4fd6 + 2ace4fa commit 3e9742a

File tree

4 files changed

+86
-24
lines changed

4 files changed

+86
-24
lines changed

.github/workflows/build.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: build
2+
defaults:
3+
run:
4+
shell: bash
5+
env:
6+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
7+
on:
8+
push:
9+
branches:
10+
- master
11+
pull_request: {}
12+
release:
13+
types: [created]
14+
jobs:
15+
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Use Node.js
21+
uses: actions/setup-node@v2
22+
with:
23+
node-version: 14.x
24+
- run: npm ci
25+
- run: npm run build
26+
- run: npm run lint
27+
- run: npm test
28+
- uses: actions/upload-artifact@v2
29+
with:
30+
name: build-artifacts
31+
path: |
32+
coverage/
33+
dist/
34+
.npmignore
35+
package.json
36+
package-lock.json
37+
LICENSE
38+
README.md
39+
40+
coverage:
41+
needs: build
42+
runs-on: ubuntu-latest
43+
steps:
44+
- if: success()
45+
uses: actions/download-artifact@v2
46+
id: download
47+
with:
48+
name: build-artifacts
49+
- uses: coverallsapp/github-action@1.1.3
50+
with:
51+
github-token: ${{ secrets.GITHUB_TOKEN }}
52+
path-to-lcov: coverage/lcov.info
53+
54+
publish:
55+
needs: build
56+
if: ${{ github.event_name == 'release' }}
57+
runs-on: ubuntu-latest
58+
steps:
59+
- if: success()
60+
uses: actions/download-artifact@v2
61+
id: download
62+
with:
63+
name: build-artifacts
64+
- uses: actions/setup-node@v2
65+
with:
66+
node-version: 14.x
67+
- run: npm publish
68+
env:
69+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-class-validator",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "React hook for validation with class-validator",
55
"main": "dist/index.js",
66
"scripts": {
@@ -28,7 +28,7 @@
2828
},
2929
"homepage": "https://github.com/anigenero/react-class-validator#readme",
3030
"peerDependencies": {
31-
"react": "^17.0.1"
31+
"react": "^17.0.0"
3232
},
3333
"devDependencies": {
3434
"@babel/core": "^7.12.13",
@@ -49,7 +49,8 @@
4949
"jest": "^26.4.2",
5050
"jest-cli": "^26.4.2",
5151
"jest-environment-jsdom-global": "^2.0.4",
52-
"react": "^17.0.1",
52+
"react": "^17.0.0",
53+
"react-dom": "^17.0.0",
5354
"react-test-renderer": "^17.0.1",
5455
"reflect-metadata": "^0.1.13",
5556
"ts-jest": "^26.5.1",

src/index.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,22 @@ export const useValidation = <T, K extends keyof T>(validationClass: Newable<T>)
4242
);
4343

4444
if (filter.length > 0) {
45+
46+
const filteredErrors =
47+
(Object.keys(validationErrors) as K[]).filter((key) =>
48+
!filter.includes(key)
49+
).reduce((accum, key) => ({
50+
...accum,
51+
[key]: validationErrors[key]
52+
}), {});
53+
54+
console.dir(filteredErrors);
55+
4556
setErrors({
46-
...validationErrors,
57+
...filteredErrors,
4758
...validation
4859
});
60+
4961
} else {
5062
setErrors(validation);
5163
}

0 commit comments

Comments
 (0)