Giter Site home page Giter Site logo

iq-scm / optimism Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leastbad/optimism

0.0 0.0 0.0 208 KB

The missing drop-in solution for realtime remote form validation in Rails.

License: MIT License

Shell 3.38% JavaScript 2.70% Ruby 93.91%

optimism's Introduction

Optimism

GitHub stars GitHub forks Twitter follow Discord

The missing drop-in solution for realtime remote form validation in Rails.

{% hint style="success" %} Optimism v0.4.1 now supports Ruby 3.0.0, thanks to Julian Rubisch and Rails 6.1, thanks to Josh LeBlanc. ๐ŸŽ‰ {% endhint %}

Why have optimism?

Optimism is an MIT-licensed Ruby on Rails gem that makes it easy to give your users instant constructive feedback if they enter invalid data into your application. Instead of dumping a list of errors at the top of your interface, Optimism provides specific instructions directly beside or below individual input elements.

You can try a ๐Ÿ‘‰ live demo ๐Ÿ‘ˆ right now.

Is optimism for you?

Are you trying to use remote forms but feeling frustrated by their inflexibility? You need to mainline a dose of Optimism, stat!

If you care about reducing churn and giving your users the best experience possible, Optimism is a great way to achieve your UX goals without having to waste time writing repetitive and brittle validation code. Properly constrained and highly opinionated, you'll be able to keep your validation logic on the server where it belongs without sacrificing the immediate response of a reactive Single Page App. Whether you're working on a complex multi-element form with a traditional Submit button or a dynamic search that delivers results as you type, Optimism chops, grinds, slices and dices your validation concerns away.

Optimism is safe and approved for all diets, religions and political appetites. Many developers find that Optimism is highly addictive and lowers stress when applied regularly.

How does optimism work?

Rails applications receive requests to update database records based on a list of proposed changes that come from a dog user submitting a form in their browser. If all proposed changes can be made without breaking any business rules, ActiveRecord can update the email address and age of the dog user. Optimism kicks in when user_params = {email: 7, age: "[email protected]"}.

When a model validation error prevents an update from succeeding, Optimism builds a list of issues that must be resolved. This list is broadcast to the browser over a websocket connection, and the live document is changed to show the necessary validation hints. No page refreshes are required and the entire process happens faster than you can blink.

Key features and advantages

  • Easy to learn, quick to implement
  • Automatically handles multi-level nested forms
  • Plays well with existing tools such as StimulusReflex, Turbolinks and even jQuery
  • Contextual user feedback in a few milliseconds
  • Supports form-based and in-line edit scenarios equally well
  • Optional support for emitting DOM events
  • Highly configurable via an optional initializer file
  • CSS framework agnostic with Bootstrap and vanilla samples provided
  • Lightweight, coming in at ~100 LOC

Try it now

The project repository lives on Github at https://github.com/leastbad/optimism and this documentation is available at https://optimism.leastbad.com

There's a live demo that you can try right now at https://optimism-demo.herokuapp.com

Even better, the source code for the demo is available on Github. The project README lists every step required to build the demo application from scratch in about five minutes.

Excited? Great! Let's setup Optimism in your Rails application now. And if you're having any trouble at all, drop by our Discord server for help.

optimism's People

Contributors

aandrieu avatar andrewmcodes avatar andryusha avatar dependabot[bot] avatar gathuku avatar joshleblanc avatar julianrubisch avatar leastbad avatar pulgamecanica avatar toproupi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.