Realtime-validations gem

Hello,

I recently wrote a new gem called realtime-validations. It is now
covering our use case, but it sure can be improved, and I will
personally improve and maintain it if there are unmet needs for any of
you.

  • Purpose

  • Why this gem ? We already have at least the great
    client-side-validations gem !

    • We like client-side-validations gem, however we believe that there
      is a ‘even better’ way to handle client side validations.
    • If you have a simple model in which you have simple validations
      (length, presence, even uniqueness…) client-side-validations will
      serve you well. However, things start to become hard if you have
      custom validators that do really strange fu, or if you have, for
      example, a :uniqueness scoped by user_id. Realtime-validations comes
      to fix this issues.
    • On complex (and probably strange) validations you need to
      replicate the server logic on javascript (at the client). This is hard
      to maintain, and someone can forget to update one or the other.
      Replicated logic in two different languages is not the best way to go.
      Also you would need to jump over language specific issues.
  • How is it done ?

    • Each time the user blurs a field (that is, focuses out a field), a
      request is sent to a special controller, that will create (or find a
      model), set the edited property and validate the model. The errors of
      that field are then sent back to the client.
  • Benefits

    • You only have validations on your model, where it should be. It
      does not matter how strange or complicated they are, they are just
      issued without problems.
    • You can also send to the server special information as which is
      the current user or similar stuff, so the model will set this
      information before setting the edited field and validate it.
      Validations with :uniqueness :scoped_by => :user_id will work nicely.

Gem: http://rubygems.org/gems/realtime-validations
Code: https://github.com/ereslibre/realtime-validations
Example: https://github.com/ereslibre/realtime-validations-examples

So please, if you need something else that should be achieved I would
be happy to know about it.

Best regards,
Rafael Fernndez Lpez

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs