Skip to content

Commit

Permalink
V8: feature: useFieldArray rules props (#8102)
Browse files Browse the repository at this point in the history
* useFieldArray rules prop

* remove required prop

* combine logic within validateField

* remove logic

* update unset method to support root node in array

* update api extrator

* update type

* update useEffect validation logic

* update api extrator

* fix submit field array error

* extract logic into its own function for update root error object

* 8.0.0-alpha.3

* update with unit tests coverage for rules validate, minLength and maxLength

* include support for required prop for consitent API and test coverage

* update API

* save some bytes

* upgrade to react 18

* Revert "upgrade to react 18"

This reverts commit d1c3bf7.

* update react

* fix cypress test

* remove render count

* udpate package and include test coverage for nested field array

* fix unit and cypress tests

* update lock file

* revert package

* avoid react native breaking change and fix test
  • Loading branch information
bluebill1049 committed Apr 9, 2022
1 parent 8647936 commit e85746d
Show file tree
Hide file tree
Showing 18 changed files with 2,096 additions and 2,636 deletions.
1 change: 1 addition & 0 deletions cypress/integration/basicSchemaValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ describe('basicSchemaValidation form validation', () => {
cy.get('input[name="lastName"] + p').contains('lastName error');
cy.get('input[name="lastName"]').type('luo123456');
cy.get('input[name="lastName"] + p').contains('lastName error');
cy.get('select[name="selectNumber"]').select('1');
cy.get('select[name="selectNumber"]').select('');
cy.get('select[name="selectNumber"] + p').contains('selectNumber error');
cy.get('select[name="selectNumber"]').select('1');
Expand Down
1 change: 1 addition & 0 deletions cypress/integration/customSchemaValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ describe('customSchemaValidation form validation', () => {
cy.get('input[name="lastName"] + p').contains('lastName error');
cy.get('input[name="lastName"]').type('luo123456');
cy.get('input[name="lastName"] + p').contains('lastName error');
cy.get('select[name="selectNumber"]').select('1');
cy.get('select[name="selectNumber"]').select('');
cy.get('select[name="selectNumber"] + p').contains('selectNumber error');
cy.get('select[name="selectNumber"]').select('1');
Expand Down
1 change: 0 additions & 1 deletion cypress/integration/isValid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('isValid', () => {
cy.get('#toggle').click();
cy.get('input[name="firstName"]').type('test');
cy.get('#isValid').contains('true');
cy.get('#renderCount').contains('6');
});

it('should showing valid correctly with schema validation and default value supplied', () => {
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-hook-form",
"description": "Performant, flexible and extensible forms library for React Hooks",
"version": "8.0.0-alpha.2",
"version": "8.0.0-alpha.3",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.mjs",
"umd:main": "dist/index.umd.js",
Expand Down Expand Up @@ -73,7 +73,7 @@
"@rollup/plugin-commonjs": "^21.0.2",
"@rollup/plugin-node-resolve": "^13.1.3",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "13.0.0-alpha.5",
"@testing-library/react": "13.0.0",
"@testing-library/react-hooks": "8.0.0-alpha.1",
"@testing-library/react-native": "^9.0.0",
"@types/jest": "^27.4.1",
Expand All @@ -84,7 +84,7 @@
"@vitejs/plugin-react-refresh": "^1.3.6",
"babel-jest": "^27.5.1",
"bundlesize": "^0.18.0",
"cypress": "9.4.1",
"cypress": "9.5.3",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-cypress": "^2.12.1",
Expand All @@ -96,18 +96,18 @@
"jest": "^27.5.1",
"lint-staged": "^12.3.5",
"prettier": "^2.5.1",
"react": "18.0.0-rc.0-next-f2a59df48-20211208",
"react-dom": "18.0.0-rc.0-next-f2a59df48-20211208",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-native": "^0.67.3",
"react-test-renderer": "18.0.0-rc.0-next-f2a59df48-20211208",
"react-test-renderer": "18.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.70.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.31.2",
"ts-jest": "^27.1.3",
"tsd": "^0.19.1",
"tsd": "^0.20.0",
"typescript": "^4.6.2"
},
"bundlesize": [
Expand Down
2 changes: 2 additions & 0 deletions reports/api-extractor.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export type FieldElement<TFieldValues extends FieldValues = FieldValues> = HTMLI
// @public (undocumented)
export type FieldError = {
type: LiteralUnion<keyof RegisterOptions, string>;
root?: FieldError;
ref?: Ref;
types?: MultipleFieldErrors;
message?: Message;
Expand Down Expand Up @@ -553,6 +554,7 @@ export type UseFieldArrayPrepend<TFieldValues, TFieldArrayName extends PathStrin
export type UseFieldArrayProps<TFieldValues extends FieldValues, TFieldArrayName extends PathString> = {
name: Auto.FieldArrayPath<TFieldValues, TFieldArrayName>;
control?: Control<TFieldValues>;
rules?: Pick<RegisterOptions<TFieldValues>, 'maxLength' | 'minLength' | 'validate' | 'required'>;
shouldUnregister?: boolean;
};

Expand Down

0 comments on commit e85746d

Please sign in to comment.