Skip to content

Commit

Permalink
feat: expose setValue on Field instance and slot props closes #4755
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed May 30, 2024
1 parent 454bc45 commit ae3772a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/short-frogs-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vee-validate": patch
---

feat: expose setValue on Field instance and slot props closes #4755
6 changes: 5 additions & 1 deletion packages/vee-validate/src/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface ComponentFieldBindingObject<TValue = any> extends SharedBinding
interface FieldSlotProps<TValue = unknown>
extends Pick<
FieldContext,
'validate' | 'resetField' | 'handleChange' | 'handleReset' | 'handleBlur' | 'setTouched' | 'setErrors'
'validate' | 'resetField' | 'handleChange' | 'handleReset' | 'handleBlur' | 'setTouched' | 'setErrors' | 'setValue'
> {
field: FieldBindingObject<TValue>;
componentField: ComponentFieldBindingObject<TValue>;
Expand Down Expand Up @@ -145,6 +145,7 @@ const FieldImpl = /** #__PURE__ */ defineComponent({
meta,
checked,
setErrors,
setValue,
} = useField(name, rules, {
validateOnMount: props.validateOnMount,
bails: props.bails,
Expand Down Expand Up @@ -242,6 +243,7 @@ const FieldImpl = /** #__PURE__ */ defineComponent({
handleBlur: sharedProps.value.onBlur,
setTouched,
setErrors,
setValue,
};
}

Expand All @@ -252,6 +254,7 @@ const FieldImpl = /** #__PURE__ */ defineComponent({
errorMessage,
setErrors,
setTouched,
setValue,
reset: resetField,
validate: validateField,
handleChange,
Expand Down Expand Up @@ -318,6 +321,7 @@ export const Field = FieldImpl as typeof FieldImpl & {
setTouched: FieldContext['setTouched'];
reset: FieldContext['resetField'];
validate: FieldContext['validate'];
setValue: FieldContext['setValue'];
handleChange: FieldContext['handleChange'];
$slots: {
default: (arg: FieldSlotProps<any>) => VNode[];
Expand Down

0 comments on commit ae3772a

Please sign in to comment.