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
What problem do you want to solve?
I want a non-mutating version of the useDefaults option.
What do you think is the correct solution to problem?
I think that instead of mutating the passed in data, we could set a property on the ajv object with the values, similar to how we do it with errors. Example:
Returning changed data as a separate object requires deep-cloning of the data-structure that is not possible in JavaScript in general case, without restricting what this data can be.
Activity
epoberezkin commentedon Aug 16, 2017
@danny-andrews given that Ajv is not limited to validating JSON data making defaults etc. mutating is a conscious decision.
If you have JSON data all that is required to preserve the original in your code is this:
Returning changed data as a separate object requires deep-cloning of the data-structure that is not possible in JavaScript in general case, without restricting what this data can be.
danny-andrews commentedon Aug 16, 2017
Thanks for the quick reply! That makes sense. Cheers!