Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V8: feature: useFieldArray rules props #8102

Merged
merged 26 commits into from Apr 9, 2022

Conversation

bluebill1049
Copy link
Member

@bluebill1049 bluebill1049 commented Mar 27, 2022

close: #6879

useFieldArray({
  name: 'test',
  rules: {
    required: true,
    minLength: 2,
    maxLength: 10,
    validate: (fieldArrayValues) => {
      if (fieldArrayValues) {
        return 'valdiate Error'
      }
    }
  }
})

errors?.test?.root?.message

ref: https://codesandbox.io/s/react-hook-form-usefieldarray-forked-iyejbp?file=/src/src/logic/createFormControl.ts

  • functional tests
  • units & automation tests
  • type tests

cc @Moshyfawn

@github-actions
Copy link
Contributor

github-actions bot commented Mar 27, 2022

Size Change: +404 B (+2%)

Total Size: 17.7 kB

Filename Size Change
dist/index.cjs.js 8.81 kB +203 B (+2%)
dist/index.umd.js 8.9 kB +201 B (+2%)

compressed-size-action

@Moshyfawn
Copy link
Member

OMG, is it React 18 time already?!

@bluebill1049
Copy link
Member Author

yes, @Moshyfawn looks pretty good. only one test failed with automation, I will look into it.

@bluebill1049
Copy link
Member Author

fixed only a rendering count correcton

@Moshyfawn
Copy link
Member

Shouldn't we update the react-18 branch instead and merge into others?

@bluebill1049
Copy link
Member Author

yea, I want to do a quick test here before merging into react 18. feel free to commit to that branch if you want to :) it's safe now.

@bluebill1049 bluebill1049 marked this pull request as ready for review April 2, 2022 23:59
@bluebill1049 bluebill1049 marked this pull request as draft April 3, 2022 00:13
@bluebill1049 bluebill1049 marked this pull request as ready for review April 3, 2022 01:03
@Moshyfawn
Copy link
Member

Sry, got sidetracked with work. Will review as soon as I wake up

@bluebill1049
Copy link
Member Author

I am going to merge this PR first, @Moshyfawn you can leave feedback here and I will address them. 🙏 No pressure on the review too, we have real work as first priority to make a living ❤️ have a good weekend buddy ✌🏻

@bluebill1049 bluebill1049 merged commit e85746d into react-18 Apr 9, 2022
@bluebill1049 bluebill1049 deleted the feature/useFieldArray-validate branch April 9, 2022 02:51
@Moshyfawn
Copy link
Member

I am going to merge this PR first, @Moshyfawn you can leave feedback here and I will address them. 🙏 No pressure on the review too, we have real work as first priority to make a living ❤️ have a good weekend buddy ✌🏻

Thanks for understanding, @bluebill1049! ❤️ Had to compromise this week, as there're a bunch of releases I have to prepare for.

Have a nice weekend, man! 🎊

bluebill1049 added a commit that referenced this pull request Jun 24, 2022
* 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
bluebill1049 added a commit that referenced this pull request Jul 13, 2022
* V8: feature: useFieldArray rules props (#8102)

* 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

* fix test and type error

* 🚔 close #8653 when useFormContext provide no generic for type check (#8654)

* close #8653 when useFormContext provide no generic for type check

* update api contract

* 🛰 useFormContext include type tests (#8656)

* Revert "🚔 close #8653 when useFormContext provide no generic for type check (#8654)"

This reverts commit 2e0c3f8.

* Revert "🛰 useFormContext include type tests (#8656)"

This reverts commit 34af5b3.

* 🥼 update changelog related to #8653

* 7.34.0-next.0

* check validation required for field array if not array or empty length

* include unit tests coverage for validate fields for array fields

* update api extrator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants