-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
uniqueItemProperties is not working #107
Comments
Difficult to say without the code sample. You may have missed adding the keyword to ajv instance |
Here is the code sample in my project: const Ajv = require('Ajv'); const validate = ajv.compile(schema); Thank you! |
Looks correct. Please submit something that can be executed to runkit.com - I.e. without private dependencies, with data object. Are you sure that the data you pass is the array? And that the environment you are in parses JSON correctly in require? Anyway, full sample in run kit will allow to understand what is wrong. |
Thank you for your help, i see now that it works. |
@Diana131194 this is not how keyword is defined, it expects each property to have unique values across all items, not the combination of properties. You can extend this keyword to accept arrays of strings in addition to strings as items in the array to pass to the keyword. So in your case the schema would look like: If it is not a massive complication it can be merged - I suggest submitting a separate issue with a feature proposal to extend it if you are going to implement it. |
Any update on this feature. |
Implimented in PR here @SimonKlausLudwig @Diana131194 |
Hi,
i am trying to use the "uniqueItemProperties" keyword in a json scema like this:
{
"type": "array",
"uniqueItemProperties": ["username"],
"items": {
"type": "object",
"required": [
"username",
"email"
],
"properties": {
"id": {
"type": "integer"
},
"username": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
}
}
}
}
But, when i am using this schema on a json that has 2 objects with the same username the validation function return true.
Any ideas what am i missing?
Thanks
The text was updated successfully, but these errors were encountered: