Skip to content

Commit

Permalink
feat: mark form values as readonly closes #4282
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed May 31, 2023
1 parent 7ce9d67 commit 05d957e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/small-ladybugs-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vee-validate': minor
---

feat: mark form values as readonly closes #4282
4 changes: 3 additions & 1 deletion packages/vee-validate/src/types/forms.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComputedRef, Ref } from 'vue';
import { ComputedRef, DeepReadonly, Ref } from 'vue';
import { MapValuesPathsToRefs, MaybeRef, GenericObject, MaybeRefOrLazy } from './common';
import { FieldValidationMetaInfo } from '../../../shared';
import { Path, PathValue } from './paths';
Expand Down Expand Up @@ -320,7 +320,9 @@ export interface FormContext<TValues extends GenericObject = GenericObject, TOut
| 'fieldArrays'
| 'markForUnmount'
| 'keepValuesOnUnmount'
| 'values'
> {
values: DeepReadonly<TValues>;
handleReset: () => void;
submitForm: (e?: unknown) => Promise<void>;
defineComponentBinds<
Expand Down
2 changes: 2 additions & 0 deletions packages/vee-validate/src/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
warn,
watchEffect,
shallowRef,
readonly,
} from 'vue';
import { klona as deepCopy } from 'klona/full';
import {
Expand Down Expand Up @@ -965,6 +966,7 @@ export function useForm<

return {
...formCtx,
values: readonly(formValues),
handleReset: () => resetForm(),
submitForm,
defineComponentBinds,
Expand Down

0 comments on commit 05d957e

Please sign in to comment.