Replies: 2 comments 2 replies
-
The problem has been that if the Validate function doesn't recognize what its validating it doesn't error. |
Beta Was this translation helpful? Give feedback.
0 replies
-
you should use additionalProperties keyword to achieve the behaviour you are describing. for example, if your schema is modified as shown below, I will emit error on unknown properties {
"type": "object",
"properties": {
"Country": {
"type": "string",
"default": null
},
},
"additionalProperties": false,
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm not entirely sure how jsonschema validates a payload, but if a schema doesn't have a field and the payload does, shouldn't that be an error?
If the schema is something like
and the payload has
I would assume it should fail because State is not expected.
For example
In Fastify they have the ability to add a schema onto endpoints and it will validate the payload against the schema and automatically remove fields that shouldn't be in the schema.
If the extra fields at least came back as a list of errors or something I would be able to create a function to loop over the errors removing the fields, but instead I get a valid response.
Beta Was this translation helpful? Give feedback.
All reactions