Client Side Validations         Brian Cardarella           @bcardarella      http://bcardarella.com
Problems...Extracted code, a real mess to maintainSupporting both Rails 2 & 3 is hardNo nested attributesInconsistent vali...
RewriteClient side validation best practicesNested attributesSer ver side fallbackValidation message rendering consistency...
Installinclude in your Gemfilerun ‘rails   g client_side_validations:install’include ‘rails.validations.js’ in your layouti...
ZOMG LIVE CODING!
Supported ValidatorsAll Rails 3 ValidatorsConditionals fallback to ser ver (:if, :unless)State taken into account (:create...
Custom ValidatorsProperly write a Rails 3 Validator
How most do it...http://railscasts.com/episodes/211-validations-in-rails-3
The better way
Remote Validators
ZOMG Moar Live   Coding!
CallbacksclientSideValidations.callbacks.element.after(element, eventData)clientSideValidations.callbacks.element.before(e...
Use Case: Gemcutter
Use Case: jQuery Mobile
Use Case: Multi-step       form
Filter Validators
Rails 3.1Engines - Assets ser ved via Sprockets
Client Side Validations                    Brian Cardarella                     @bcardarella                http://bcardar...
Client Side Validations
Client Side Validations
Client Side Validations
Client Side Validations
Client Side Validations
Client Side Validations
Client Side Validations
Client Side Validations
Client Side Validations
Client Side Validations
Client Side Validations
Client Side Validations
Upcoming SlideShare
Loading in …5
×

Client Side Validations

2,439 views

Published on

Rails 3 Client Side Validations gem

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,439
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
23
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • When compared to our control version, the inline validation form with the best performance (after validation) showed compelling improvements across all the data we measured. Specifically, we saw:\na 22% increase in success rates,\na 22% decrease in errors made,\na 31% increase in satisfaction rating,\na 42% decrease in completion times, and\na 47% decrease in the number of eye fixations.\n\n
  • \n
  • \n
  • \n
  • \n
  • Does not support i18n\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Client Side Validations

    1. 1. Client Side Validations Brian Cardarella @bcardarella http://bcardarella.com
    2. 2. Problems...Extracted code, a real mess to maintainSupporting both Rails 2 & 3 is hardNo nested attributesInconsistent validation modeletc...
    3. 3. RewriteClient side validation best practicesNested attributesSer ver side fallbackValidation message rendering consistencyCustom validatorsCustom FormBuildersInternationalized messagesRails 3 onlyjQuery only
    4. 4. Installinclude in your Gemfilerun ‘rails g client_side_validations:install’include ‘rails.validations.js’ in your layoutif you’re not using a custom FormBuilder (i.e.Formtastic or SimpleForm) uncomment thefield_error_proc in the initializer
    5. 5. ZOMG LIVE CODING!
    6. 6. Supported ValidatorsAll Rails 3 ValidatorsConditionals fallback to ser ver (:if, :unless)State taken into account (:create, :update)
    7. 7. Custom ValidatorsProperly write a Rails 3 Validator
    8. 8. How most do it...http://railscasts.com/episodes/211-validations-in-rails-3
    9. 9. The better way
    10. 10. Remote Validators
    11. 11. ZOMG Moar Live Coding!
    12. 12. CallbacksclientSideValidations.callbacks.element.after(element, eventData)clientSideValidations.callbacks.element.before(element, eventData)clientSideValidations.callbacks.element.fail(element, message, callback, eventData)clientSideValidations.callbacks.element.pass(element, callback, eventData)clientSideValidations.callbacks.form.after(form, eventData)clientSideValidations.callbacks.form.before(form, eventData)clientSideValidations.callbacks.form.fail(form, eventData)clientSideValidations.callbacks.form.pass(form, eventData)
    13. 13. Use Case: Gemcutter
    14. 14. Use Case: jQuery Mobile
    15. 15. Use Case: Multi-step form
    16. 16. Filter Validators
    17. 17. Rails 3.1Engines - Assets ser ved via Sprockets
    18. 18. Client Side Validations Brian Cardarella @bcardarella http://bcardarella.com https://github.com/bcardarellahttps://github.com/bcardarella/client_side_validations

    ×