Closed filipedeschamps closed 8 years ago
Hi,
I don't think this exists, I don't recall implementing it, but believe I considered it.
I imagine it would be fairly trivial to implement, looking at the code again, we could possibly add a strict
property to the descriptor passed to the schema and then when a property is encountered in the source object that does not exist in the schema generate a validation error.
Is this something that is important to you? Can you describe a use-case please?
@freeformsystems thank you for your reply!
Our use-case was related to security and due to the emergency of the situation, we had to make a workaround :)
Basically, if you don't strict to the schema, you can inject any other key to your object model and bypass the validation of that key.
Best regards,
Draft implementation for nested objects in 17e2e7917b23e68cf850690d369a06bf4610be62.
Needs work to operate at the root source object level as well.
Set additional
to false
for a rule with an object
type and an error is raised if the source object contains additional fields, see:
https://github.com/freeformsystems/async-validate/blob/master/test/spec/object-additional.js
I need to test this a little more but I think it should be working with the addition of the ability to apply validation rules to the root source
object in a076784d75c7606cd4f829d17a314a378e13a951.
Relevant test spec is: https://github.com/freeformsystems/async-validate/blob/master/test/spec/source-additional.js
Closing as implemented, this is available in 0.4.5
and the test spec for root and deep objects is here:
https://github.com/freeformsystems/async-validate/blob/master/test/spec/additional.js
Re-open if you find an issue with this functionality.
Hi guys!
Do you know if there's anything like JSON schema "additionalProperties" in async validate do refuse validation if there's any additional properties been sent?
Best regards!
cc @marcosrava