Skip to content

Commit fe53179

Browse files
authored
* feat: V2 init BREAKING CHANGE: there will be some breaking changes in the next versions * feat: improve modules support * fix: yup resolver typescript errors * Fix: vest validate all criteria + better TypeSript support + add tests * test: add components test to ensure TypeScript is working as expected Related to react-hook-form#97 * chore: improve zod resolvers types * chore(eslint): remove warnings * test: add severals tests & improve typings * chore: setup compressed-size * test: update describe * feat: add Zod sync validation (react-hook-form#114) * feat: add Joi sync validation (react-hook-form#116) * feat: add Joi sync validation * fix(joi): sync error * test: add validateAllCriteria test * test(joi): update test description * feat: add Yup sync validation (react-hook-form#115) * feat: add Yup sync validation * test(zod): add tests * test(zod): update tests * test(yup): add validateAllCriteria test * feat: add Vest sync validation + update to v3 (react-hook-form#117) * feat: update to react-hook-form v7 BREAKING CHANGE: Require react-hook-form >= 7 * chore: fix typescript error (react-hook-form#123) * chore: update deps * chore: fix TypeScript error * refactor: replace deprecated transformToNestObject (react-hook-form#125) * fix: pass down Joi context (react-hook-form#124) * fix: zod union error + reduce size (react-hook-form#126) * test: extract fixtures * fix: zod resolver union error + reduce resolver size * feat: add error's ref (react-hook-form#127) * feat: add error's ref * test: add error's ref + extract fixtures * test: add nested test * refactor: rename toNestObject to toNestError * Reduce superstruct resolver size (react-hook-form#128) * test: extract test's fixtures * test: jest fixtures config * perf: reduce superstruct resolver size * feat: add error's ref * test: add error's ref + extract fixtures * test: add nested test * refactor: rename toNestObject to toNestError * refactor: remove duplicate line * chore: update superstruct peer dep * perf: reduce vest resolver size (react-hook-form#129) * test: extract test's fixtures * test: jest fixtures config * perf: reduce superstruct resolver size * feat: add error's ref * test: add error's ref + extract fixtures * test: add nested test * refactor: rename toNestObject to toNestError * refactor: remove duplicate line * perf: recude vest resolver bundle size * perf: reduce joi resolver's size (react-hook-form#131) * perf: reduce Joi resolver's size * perf: reduce Vest resolver's size * perf: reduce yup resolver's size (react-hook-form#130) * refactor: remove convertArrayToPathName (react-hook-form#132) * perf: reduce joi and yup bundle size (react-hook-form#134) * fix(types): add Lazy schema support to resolver * docs: v2 doc (react-hook-form#136)
1 parent 5672e65 commit fe53179

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3609
-2752
lines changed

.github/FUNDING.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# These are supported funding model platforms
2+
3+
github: [bluebill1049, jorisre]
4+
patreon: bluebill1049
5+
open_collective: react-hook-form

.github/ISSUE_TEMPLATE/bug_report.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
**To Reproduce**
13+
Steps to reproduce the behavior:
14+
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Codesandbox link (Required)**
21+
Include a codesandbox will help us to investigate the issue quicker.
22+
23+
- [Yup resolver](https://codesandbox.io/s/react-hook-form-validationschema-v6-2l77g) Template
24+
- [Zod resolver](https://codesandbox.io/s/react-hook-form-zod-resolver-example-forked-ko5ll) Template
25+
- [Joi resolver](https://codesandbox.io/s/react-hook-form-joiresolver-v6-yejqe) Template
26+
- [Superstruct resolver](https://codesandbox.io/s/react-hook-form-v6-superstructresolver-ed67i) Template
27+
- [Vest resolver](https://codesandbox.io/s/vest-k6gbd) Template
28+
- [Custom resolver](https://codesandbox.io/s/react-hook-form-customresoliver-v6-h4ti6) Template
29+
30+
**Expected behavior**
31+
A clear and concise description of what you expected to happen.
32+
33+
**Screenshots**
34+
If applicable, add screenshots to help explain your problem.
35+
36+
**Desktop (please complete the following information):**
37+
38+
- OS: [e.g. iOS]
39+
- Browser [e.g. chrome, safari]
40+
- Version [e.g. 22]
41+
42+
**Smartphone (please complete the following information):**
43+
44+
- Device: [e.g. iPhone6]
45+
- OS: [e.g. iOS8.1]
46+
- Browser [e.g. stock browser, safari]
47+
- Version [e.g. 22]
48+
49+
**Additional context**
50+
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/config.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Ask a question
4+
url: https://github.com/react-hook-form/react-hook-form/discussions
5+
about: Ask questions and discuss with other community members
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
---
8+
9+
**Is your feature request related to a problem? Please describe.**
10+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11+
12+
**Describe the solution you'd like**
13+
A clear and concise description of what you want to happen.
14+
15+
**Describe alternatives you've considered**
16+
A clear and concise description of any alternative solutions or features you've considered.
17+
18+
**Additional context**
19+
Add any other context or screenshots about the feature request here.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Fixes #
2+
3+
## Proposed Changes
4+
5+
-
6+
-
7+
-

.github/workflows/compressedSize.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Compressed Size
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: preactjs/compressed-size-action@v2
12+
with:
13+
repo-token: '${{ secrets.GITHUB_TOKEN }}'

.github/workflows/main.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
push:
44
branches:
55
- master
6+
- beta
67
pull_request:
78
paths-ignore:
89
- '.gitignore'
@@ -40,7 +41,7 @@ jobs:
4041
publish-module:
4142
name: 'Publish Module to NPM on Node ${{ matrix.node }} and ${{ matrix.os }}'
4243
needs: build
43-
if: github.repository == 'react-hook-form/resolvers' && (github.ref =='refs/heads/master')
44+
if: github.repository == 'react-hook-form/resolvers' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta')
4445
runs-on: ubuntu-latest
4546
steps:
4647
- name: Checkout repo

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ dist
2828
.idea/
2929
.rpt2_cache
3030
.coveralls.yml
31-
package-lock.json
31+
package-lock.json

.vscode/settings.json

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"typescriptreact"
77
],
88
"prettier.configPath": "./.prettierrc",
9-
"eslint.enable": true,
109
"editor.formatOnSave": true,
1110
"editor.codeActionsOnSave": {
1211
"source.fixAll.eslint": true

CODE_OF_CONDUCT.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at bluebill1049@hotmail.com. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

CONTRIBUTING.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Contributing to `React Hook Form`
2+
3+
As the creators and maintainers of this project, we want to ensure that `resolvers` lives and continues to grow and evolve. We would like to encourage everyone to help and support this library by contributing.
4+
5+
## Code contributions
6+
7+
Here is a quick guide to doing code contributions to the library.
8+
9+
1. Fork and clone the repo to your local machine `git clone https://github.com/YOUR_GITHUB_USERNAME/resolvers.git`
10+
11+
2. Create a new branch from `master` with a meaningful name for a new feature or an issue you want to work on: `git checkout -b your-meaningful-branch-name`
12+
13+
3. Install packages by running:
14+
15+
> yarn
16+
17+
4. If you've added a code that should be tested, ensure the test suite still passes.
18+
19+
> yarn test
20+
21+
5. Try to write some unit tests to cover as much of your code as possible.
22+
23+
6. Ensure your code lints without errors.
24+
25+
> yarn lint
26+
27+
7. Ensure build passes.
28+
29+
> yarn build
30+
31+
8. Push your branch: `git push -u origin your-meaningful-branch-name`
32+
33+
9. Submit a pull request to the upstream resolvers repository.
34+
35+
10. Choose a descriptive title and describe your changes briefly.
36+
37+
## Coding style
38+
39+
Please follow the coding style of the project. React Hook Form uses eslint and prettier. If possible, enable their respective plugins in your editor to get real-time feedback. The linting can be run manually with the following command: `yarn lint`
40+
41+
## License
42+
43+
By contributing your code to the resolvers GitHub repository, you agree to license your contribution under the MIT license.
44+
45+
### Contributors
46+
47+
Thank you to all the people who have already contributed to React Hook Form!
48+
49+
<img src="https://opencollective.com/react-hook-form/contributors.svg?width=950" />

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ We are moving away from native support for Yup validation. We are now supporting
2626

2727
## API
2828

29-
`resolver(schema: object, config?: object)`
29+
`resolver(schema: object, schemaOptions?: object, resolverOptions: { mode: 'async' | 'sync' })`
3030

31-
| | type | Required | Description |
32-
| ------ | -------- | -------- | -------------------------------------- |
33-
| schema | `object` || validation schema |
34-
| config | `object` | | validation schema configuration object |
31+
| | type | Required | Description |
32+
| --------------- | -------- | -------- | --------------------------------------------- |
33+
| schema | `object` || validation schema |
34+
| schemaOptions | `object` | | validation library schema options |
35+
| resolverOptions | `object` | | resolver options, `async` is the default mode |
3536

3637
## Quickstart
3738

config/build-ie11.js

-54
This file was deleted.

config/check-ie11.js

-18
This file was deleted.

config/get-resolvers-name.js

-7
This file was deleted.

jest.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
module.exports = {
22
preset: 'ts-jest',
3+
testEnvironment: 'jsdom',
34
restoreMocks: true,
45
testMatch: ['**/__tests__/**/*.+(js|jsx|ts|tsx)'],
56
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
7+
testPathIgnorePatterns: ['/__fixtures__/'],
68
moduleNameMapper: {
79
'^@hookform/resolvers$': '<rootDir>/src',
810
},
11+
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
912
};

0 commit comments

Comments
 (0)