Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"additionalProperties" behavior like JSON Schema #18

Closed
filipedeschamps opened this issue Mar 16, 2015 · 5 comments
Closed

"additionalProperties" behavior like JSON Schema #18

filipedeschamps opened this issue Mar 16, 2015 · 5 comments

Comments

@filipedeschamps
Copy link
Collaborator

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

@tmpfs
Copy link
Owner

tmpfs commented Mar 17, 2015

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?

@filipedeschamps
Copy link
Collaborator Author

@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,

@tmpfs
Copy link
Owner

tmpfs commented Sep 12, 2015

Draft implementation for nested objects in 17e2e79.

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

@tmpfs
Copy link
Owner

tmpfs commented Sep 12, 2015

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 a076784.

Relevant test spec is: https://github.com/freeformsystems/async-validate/blob/master/test/spec/source-additional.js

@tmpfs
Copy link
Owner

tmpfs commented Sep 12, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants