You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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": "[email protected]" } }
This is what I want to get since I didn't touch any input, and values where set up.
Expected behavior getValues 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):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
javier-brenes-zen
changed the title
AJV Resolver - When ajv schema contains default for certain properties, getValues() returns the form data with properties overwriten
AJV Resolver - When ajv schema contains default for certain properties, getValues() returns the form data with properties overwritten
Nov 15, 2023
Describe the bug
I have an ajv schema that contains
default
definitions for some properties.Then when calling
useForm
I passvalues
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 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.
The text was updated successfully, but these errors were encountered: