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

Strict mode #46

Open
Cyri-L opened this issue Mar 1, 2016 · 5 comments
Open

Strict mode #46

Cyri-L opened this issue Mar 1, 2016 · 5 comments

Comments

@Cyri-L
Copy link

Cyri-L commented Mar 1, 2016

How do we force strict mode on the schemas ? Meaning that unspecified keys are unauthorized ? Thanks a lot

@molnarg
Copy link
Owner

molnarg commented Mar 2, 2016

Did you try "*": null ?

Cyri-L [email protected] ezt írta (időpont: 2016. márc. 1., K
23:51):

How do we force strict mode on the schemas ? Meaning that unspecified keys
are unauthorized ? Thanks a lot


Reply to this email directly or view it on GitHub
#46.

@Cyri-L
Copy link
Author

Cyri-L commented Mar 2, 2016

The problem is that by putting "*":null you allow properties to have value == void 0, which is not equal to !hasOwnProperty. Where should I add this feature into your structure?

@molnarg
Copy link
Owner

molnarg commented Mar 2, 2016

Null should mean that there's no such property. Undwfined means it has one,
but the value is null or undefined. If it doesn't work that way, it's
probably a bug.

Cyri-L [email protected] ezt írta (időpont: 2016. márc. 2., Sze
9:26):

The problem is that by putting "*" you allow properties to have value ==
void 0, which is not equal to !hasOwnProperty. Where should I add this
feature into your structure?


Reply to this email directly or view it on GitHub
#46 (comment).

@Cyri-L
Copy link
Author

Cyri-L commented Mar 2, 2016

Thank you, unfortunately it doesn't fully work. "*":null prevents from adding unspecified keys but the errors related to those additional keys are not reported into .errors() function

@harmvandendorpel
Copy link

harmvandendorpel commented Jul 11, 2016

I think this should be achieved by using the property additionalProperties. Don't know where to set its value though.

"This provides a default property definition for all properties that are
not explicitly defined in an object type definition. The value must be a
schema. If false is provided, no additional properties are allowed, and the
schema can not be extended. The default value is an empty schema which
allows any value for additional properties. "

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

3 participants