Describe the bug
I have an ajv schema that contains default definitions for some properties.
Then when calling useForm I pass values with populated data that I retrieved from DB, I can see the data being rendered in UI.
When I call getValues function to get the form data without touching any of the inputs, the returned data by getValues no longer contains the initial info provided via values but instead those properties that had a default attribute in the ajv schema are overwritten.
Call getValues() without modifying any of the inputs, you will get lastName and email with their default values from the ajv schema, this is wrong because those properties contain info that was passed to the values property in UseForm.
This is what I am getting:
{ "user": { "name": "Javier", "lastName": "A random lastName", "email": "this@not.com" } }
This is what I want to get since I didn't touch any input, and values where set up.
Expected behaviorgetValues should return the set up data via values if none of the inputs were touched.
default values in ajv schema should only be used when the property is not part of the form data already.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Describe the bug I have an ajv schema that contains
default
definitions for some properties. Then when callinguseForm
I passvalues
with populated data that I retrieved from DB, I can see the data being rendered in UI. When I callgetValues
function to get the form data without touching any of the inputs, the returned data bygetValues
no longer contains the initial info provided viavalues
but instead those properties that had adefault
attribute in the ajv schema are overwritten.To Reproduce Steps to reproduce the behavior:
useForm
on your component make sure you addvalues
:getValues()
without modifying any of the inputs, you will getlastName
andemail
with their default values from the ajv schema, this is wrong because those properties contain info that was passed to thevalues
property inUseForm
.This is what I am getting:
This is what I want to get since I didn't touch any input, and
values
where set up.Codesandbox link (Required) https://stackblitz.com/edit/stackblitz-starters-purvrb?file=src%2FApp.js
Expected behavior
getValues
should return the set up data viavalues
if none of the inputs were touched.default
values in ajv schema should only be used when the property is not part of the form data already.Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context Add any other context about the problem here.