LIVR icon indicating copy to clipboard operation
LIVR copied to clipboard

add LIVR Swift validator to readme

Open marinofelipe opened this issue 6 years ago • 6 comments

Hi there 👍

I'm currently working on the LIVR Swift validator.

The most part is done and it's just left some of the modifiers and aliasing rules. I'm also following the test suite.

Some behaviors, like in the experimental or rule, where the returned error is the last rule error, are changed until now because, in Swift, json is an unordered list, so there's no guarantee that the last item in rules json is the last after it is loaded into code.

Some code improvements and more will be done. But, I'm enjoying the challenge right now :)!

If you prefer to wait until it's entirely done, to merge it, for me it's ok!

I have some ideas about LIVR and the experience my teammates and I are having, and when we pack it all up I would like to share them.

Thanks!

marinofelipe avatar Oct 01 '18 04:10 marinofelipe

@marinofelipe, great! Thank you! Let's wait until it's entirely done. But I am will be happy to help with any issues if you have any.

in Swift, json is an unordered list, so there's no guarantee that the last item in rules json is the last after it is loaded into code

As for this, it seems very strange for me. We are working with a list, why should it be unordered? Usually, Dictionaries/Sets are unordered (the same in Perl). But if we talking it should be ordered. Please, correct me if I am wrong.

koorchik avatar Oct 03 '18 19:10 koorchik

Hi @koorchik!

Thank you very much! 😄

Sorry, my mistake and I didn't explain the point very well. This behavior affects the test suite only.

In tests, the JSON's are uploaded from the bundle, and it's not guaranteed that the conversion from it to dictionary has the expected order of elements, so for tests only, there's no guarantee that the last error is the one returned (when validating with OR). However, when using the validator it will respect the dictionary given order. It's a problem outside the validator scope, where in iOS, converting JSON to a Swift's dictionary, the order is not respected. So, I just wanted to advise from this kind of treatment in tests, related to the JSON test files itself.

To exemplify, when the rules are converted from bundle to dictionary it can alter it's rules order as this:

"id1-1": { "or": ["email", "positive_integer" ] },

to

["id1-1": ["or": ["positive_integer", "email"]]]

where the returned error code will be WRONG_EMAIL instead of NOT_POSITIVE_INTEGER

I updated the expected error.json to match this return, but the validator itself follows the Dictionary given order.

marinofelipe avatar Oct 03 '18 21:10 marinofelipe

Hi @koorchik, how are you doing?

The Swift Livr validator is released. There are some improvements to be made, but its base is already entirely done.

marinofelipe avatar Oct 10 '18 11:10 marinofelipe

Hi @koorchik. We have moved the LIVR Swift validator to the ownership of @grupoZap. There we are using LIVR to share validation rules across many clients in our great products.

We are still looking forward for this pull request to be merged. Could you please give us any feedback? Thanks.

marinofelipe avatar Jul 04 '19 03:07 marinofelipe

Hi, @marinofelipe

Sorry, just lost the ticket. I've added your implementation to livr-spec.org (to main README and to the page with implementations list too).

Moreover, I've created a page with LIVR users - http://livr-spec.org/users.html . Is it ok if I will add https://www.grupozap.com/ to the list too?

koorchik avatar Jul 30 '19 10:07 koorchik

Hi @koorchik, there's no problem.

Thanks, that's nice. Yes, sure. It would be nice if you added Grupo Zap to the users page :).

marinofelipe avatar Jul 31 '19 20:07 marinofelipe