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

Update error "has additional properties" to have array with additional properties names #102

Open
ceoworks opened this issue Dec 17, 2015 · 4 comments

Comments

@ceoworks
Copy link

Suppose we have a schema with such a properties userSchema = {name, surname}
But in he input we receive object that looks like input = {name, surname, login}
When validate accross userSchema, error must contain 'forbiddenProperties' array besides message and property fields.
Example: { message: 'has additional properties', property: 'data', additonalProperties: [ 'login' ] }

Kind Regards

@LinusU
Copy link
Collaborator

LinusU commented Feb 16, 2016

I think that this would be awesome!

@dmeznaric
Copy link

this is already possible. You only need to define schema properly.
For your example @ceoworks login should be defined as optional property.

Something like this:

 var schema = {
        type: 'object',
        properties: {
          name: {type: 'string' },
          surname: {type: 'string' },
          login: {type: 'string' }
        },
        required: [ "name", "surname" ],
        optional: [ "login" ],
        additionalProperties: false
      };

@emilbayes
Copy link
Collaborator

I believe this can be closed given @dmeznaric solution

@LinusU
Copy link
Collaborator

LinusU commented Nov 30, 2016

I don't think that this is resolved, the original issue was about giving the property that was extra in the error output. I don't think that this is solved yet...

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

4 participants