-
-
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
Add unique item property keyword. #19
Add unique item property keyword. #19
Conversation
@blainesch can you change it to false so I can see it fail when it shouldn't? How can I say why it fails otherwise? btw, the implementation of uniqueItems in Ajv can be helpful. |
So a |
I pushed the change you were asking for. |
https://runkit.com/esp/591f1ba7015d6e0012243737 - works here maybe it's because you have two tests with the same name? not sure. You need to debug. |
Yes, implementation can be more more efficient :) (three loops?), but what I meant was that you may find some ideas there and figure out why it's not working here :). Compile vs. validate won't make much difference as you don't need to manipulate the schema - just to iterate the keys... A more important thing is that it probably should check deep equality rather than by reference, in the same way uniqueItems is specified. If it were to be added to the spec it would definitely be deep equality. Ajv has "equal" function inside (for performance reasons - it's faster than all the libs I saw, probably should be extracted), not sure what is the better way to do here. |
Looks like I needed to define it in |
right, it simply wasn't added to the instance |
So if you use compile, it will be passed schema (keys), parentSchema and schema compilation context (it). There is it.util. I suggest exposing equal that Ajv uses there (needs change in Ajv) so you can use definition = {
compile: function(keys, parentSchema, it) {
var equal = it.util.equal;
return function(data) {
// validation here can use equal
};
},
// ...
} |
6801b0e
to
b23dc1a
Compare
Sweet, how's that? :D |
@epoberezkin any update? |
@blainesch I didn't realise it's finished. Can you add a section in readme please? |
Yeah give me a few minutes [: |
b23dc1a
to
f9a4dfb
Compare
f9a4dfb
to
2e530f6
Compare
2e530f6
to
edc78d5
Compare
Thanks! |
@epoberezkin my second test is correctly failing, and it should fail, but when I change
valid
tofalse
, like I believe it should be, it fails still and I'm not sure why.Can you point me in the right direction?