Skip to content

Commit

Permalink
feat: add validate in $useFieldArray type
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Schleemann committed Sep 18, 2024
1 parent b889a76 commit 596e68a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@atmina/formbuilder",
"version": "2.1.0",
"version": "2.1.1",
"description": "A strongly-typed alternative API for React Hook Form.",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
7 changes: 5 additions & 2 deletions src/formbuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function createFormBuilder<TFieldValues extends FieldValues>(
name: currentPath as FieldArrayPath<TFieldValues>,
keyName: '$key' as const,
control,
...props,
...(props as Record<string, unknown>),
});
return {
fields: fields.map(({$key}, i) =>
Expand Down Expand Up @@ -354,7 +354,10 @@ type $UseWatchCommonProps = Omit<
type $UseStateProps = Omit<UseFormStateProps<never>, 'name' | 'control'>;

type $UseFieldArrayProps<T> = {
rules?: Pick<RegisterOptions<T>, 'maxLength' | 'minLength' | 'required'>;
rules?: Pick<
RegisterOptions<T>,
'maxLength' | 'minLength' | 'required' | 'validate'
>;
shouldUnregister?: boolean;
};

Expand Down

0 comments on commit 596e68a

Please sign in to comment.