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

Default required : true? #135

Closed
AJB99 opened this issue Jan 20, 2017 · 1 comment
Closed

Default required : true? #135

AJB99 opened this issue Jan 20, 2017 · 1 comment

Comments

@AJB99
Copy link

AJB99 commented Jan 20, 2017

I'd like to have all properties of any given data object being validated to be required by default. Additionally, I'd like additionalProperties to default to false.

Is this currently possible without hacking the code?

@LinusU
Copy link
Collaborator

LinusU commented Jan 20, 2017

This is not currently possibly, but might I suggest that you use your own function that does this for you, something like this:

function createSchema (properties) {
  return {
    type: 'object',
    additionalProperties: false,
    required: Object.keys(properties),
    properties: properties
  }
}

also, instead of setting required to true, I would recommend using the new format (4) where required is an array of the keys that should be required.

@LinusU LinusU closed this as completed Aug 13, 2018
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