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 version of Ajv are you using? 5.2.2, latest at the moment of writing
The problem you want to solve
I don't want to modify properties in a different scope, to prevent unwanted side-effects. Side-effects are
often responsible for causing bugs.
varvalidate=ajv.compile(schema);varisValid=validate(data);// THROW: Can't add property bar, object is not extensible// expected results without `deepFreeze`console.log(validate.errors);// nullconsole.log(isValid);// trueconsole.log(data);// { foo: 1, bar: 'baz' }
What do you think is the correct solution to the problem?
The correct solution would be to make ajv behave side-effect free. Make the validate function side-effect free / immutable, don't reassign arguments there.
If validate does not modify data, be sure that result.data === data. When it does modify data (because of applying defaults, or Coercing data types), result.data !== data
Will you be able to implement it
At this moment probably not, because of lack of time. Maybe in the future, but don't hold your breath.
The text was updated successfully, but these errors were encountered:
What version of Ajv are you using?
5.2.2
, latest at the moment of writingThe problem you want to solve
I don't want to modify properties in a different scope, to prevent unwanted side-effects. Side-effects are
often responsible for causing bugs.
schema:
issue:
What do you think is the correct solution to the problem?
The correct solution would be to make
ajv
behave side-effect free. Make thevalidate
function side-effect free / immutable, don't reassign arguments there.If
validate
does not modify data, be sure thatresult.data === data
. When it does modify data (because of applying defaults, or Coercing data types),result.data !== data
Will you be able to implement it
At this moment probably not, because of lack of time. Maybe in the future, but don't hold your breath.
The text was updated successfully, but these errors were encountered: