uix_validations 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f42e5cab37cb240ef7553b7854285893179f6077cd6c79176eca95884f61176
4
- data.tar.gz: 3508693ed965fa9a2807cc8c9fd769f510c345802fbab894b6b63f79efa86f05
3
+ metadata.gz: 38bd0d741cc6a00414d96b740f3a7f6240a1804fa14386dcb52e788552af17e4
4
+ data.tar.gz: da6fc6e640daaa73cee647916eece8fd25e59de232c0847bd68b82f5f2126a07
5
5
  SHA512:
6
- metadata.gz: 11bd1069604223f419cea9bbae0a77cbc9223d493392e2dc06c97741815970820d6099251b5ec47fce5809d8589bedbf090e29bf2db68f94759ae72120cac5e9
7
- data.tar.gz: 2c651e8b7fc01c5061c738ce91a67206947ea12fbd8ccd291caf983141f6624c323821af06fc0baab764d70fd365b0caec3abd7c32c2044ec5e25906a5f190a5
6
+ metadata.gz: 0aa08fd1a4f873e3e70bdd0e2e5b59aeb1578fe723b4664315e42129bc942ad07662616d7be3db2b1528212d8e9ed11deec54d579ecdd117e9ae5b4103ab0a56
7
+ data.tar.gz: e4ebad797a8e6f1d4fee52dd220592fd547fbe10427c0cc116bceed74b48be95f8dd0216c7c99066689ec8f4e3ce06f9ee0e05004b2cb752e76079746dfcb414
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .DS_Store
10
+ *.gem
11
+ *.rbc
12
+ *.sassc
13
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in uix_validations.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 lucasandrad
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,132 @@
1
+ # UixValidations
2
+
3
+ `uix_validations` is a gem that provides Js functions for real time validations.
4
+
5
+ Uix is the abbreviation that I "created" for UI and UX, since this gem has some things from both worlds
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'uix_validations'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ bundle install
18
+
19
+
20
+ Than in your Rails project add this line at `app/assets/javascripts/application.js`
21
+
22
+ ```
23
+ //= require uix_validations
24
+ ```
25
+
26
+ And this import at `app/assets/stylesheets/application.scss`
27
+
28
+ ```scss
29
+ @import "uix_validations";
30
+ ```
31
+
32
+ If you are using `application.css` insted of `application.scss`, you can import uix_validations into any `.scss` file.
33
+
34
+ ## Usage
35
+
36
+ ### Live demo
37
+ Check out this live demo using Uix Validations: [uix_validations_demo link here](https://uix-validations-demo.herokuapp.com/)
38
+
39
+ ### Examples
40
+ Real time validation for numbers:
41
+ ```html
42
+ <!-- html -->
43
+ <div class="input">
44
+ <%= f.label 'Validation Number' %><br>
45
+ <%= f.text_field :title, class: 'input-text', id: 'input-num' %>
46
+ <!-- Add this div under your input -->
47
+ <div class="uix-validation" id="vali1">
48
+ Should have only numbers
49
+ </div>
50
+ </div>
51
+
52
+ <script>
53
+ // pass your input Id and your div Id
54
+ validateNumber("#input-num", "#vali1");
55
+ </script>
56
+ ```
57
+ ---
58
+ Real time validation for characters
59
+ ```html
60
+ <div class="input">
61
+ <%= f.label 'Validation Character' %><br>
62
+ <%= f.text_field :title, class: 'input-text', id: 'input-char' %>
63
+ <div class="uix-validation" id="vali2">
64
+ Should have only characters
65
+ </div>
66
+ </div>
67
+
68
+ <script>
69
+ validateCharacter("#input-char", "#vali2");
70
+ </script>
71
+ ```
72
+ ---
73
+ Real time validation for characters with length 5 - 10
74
+ ```html
75
+ <script>
76
+ validateCharacterLength("#input-num", "#vali1", [5,10]);
77
+ </script>
78
+ ```
79
+
80
+ ### Table with all functions
81
+
82
+ | Js Function | What is it for? |
83
+ |---|---|
84
+ | `validateNumber(input_id, div_id)` | Valid if there are only numbers |
85
+ | `validateNumberRange(input_id, div_id, [0, 2])` | For now validates only the length of the number, example: [0,2] it's 00 to 99 |
86
+ | `validateCharacter(input_id, div_id)` | Valid if there are only Characters |
87
+ | `validateCharacterLength(input_id, div_id, [0, 2])` | Valid if there are only Characters with the correct length |
88
+ | `validateNonDigit(input_id, div_id)` | Valid if there is anything except digits |
89
+ | `validateNonDigitLength(input_id, div_id, [0, 2])` | Valid if there is anything except digits with the correct length |
90
+ | `validateJustLength(input_id, div_id, [0,2])` | Valid if the value has the correct length |
91
+ | `validateEmail(input_id, div_id)` | Checks for a valid email |
92
+ | `validateRegex(input_id, div_id, custom_regex)` | Validate a custom regex |
93
+ | `validateStrongPassword(input_id, div_id)` | Validate if the password has: at least one digit, at least one character and at least 8 characters |
94
+ | `validateVeryStrongPassword(input_id, div_id)` | Validate if the password has: at least one digit, at least one upcase character, at least one downcase character and at least 8 characters |
95
+
96
+ ### Customize
97
+ You can customize the style of the div with the validation message<br>
98
+ Here is the flow of the validation:<br>
99
+ - When the page loads, the class of validation div is: `class="uix-validation"`
100
+ - When the user is typing the class change to: `class="uix-validation uix-default"`
101
+ - If the input.value is valid the div class change to: `class="uix-validation uix-valid"`
102
+ - If the input.value is invalid, when user click out of the input the class change to: `class="uix-validation uix-invalid"`
103
+
104
+ So if the `.uix-valid` and `.uix-invalid` styles are not exactly what you want, you can change the style as you want.
105
+
106
+ ## Good practices about real time validations
107
+ This gem is inspired in [Luke Wroblewski study, (article here)](https://alistapart.com/article/inline-validation-in-web-forms) about validation in web forms. This article was published in 2009 but it's still a excellent reference about form validations. Many writers use Luke study as reference in other articles [Example here](https://designmodo.com/ux-form-validation/)
108
+
109
+ **This gem follow this practices:**
110
+ - Show the validation at the right time (right after the user has submitted the input value)
111
+ - Show the validation at the right place (under the input)
112
+ - Correct colors (not too red and not too green)
113
+ - The colors change at the right moment (while the user types validations don't turn red, only if he click outside the input, but if the input value is valid the validations turn green, because is good to know that the value is correct just in time)
114
+ - Validations don't have a alarming design (I am not a design but I tried to make then clean and understandable, something like the ideas of minimalist design)
115
+
116
+ ## Write good messages
117
+
118
+ Good messages can be a differential in your forms. Don't scare your users with alarming messages, like:<br>**Error: this is wrong. Use just numbers**<br>
119
+
120
+ Instead you need to focus in what is wrong and help the user to fix it. Something like:<br>
121
+ **Should have onlye numbers. Ex: 99887766**
122
+
123
+ You can read more about it here: [UX Movement, post about good messages](http://uxmovement.com/forms/how-to-make-your-form-error-messages-more-reassuring/)
124
+
125
+
126
+ ## Contributing
127
+
128
+ Bug reports and pull requests are welcome on GitHub at https://github.com/lucasandrad/uix_validations.
129
+
130
+ ## License
131
+
132
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "uix_validations"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,6 @@
1
+ require "uix_validations/version"
2
+ require "uix_validations/engine"
3
+
4
+ module UixValidations
5
+
6
+ end
@@ -0,0 +1,4 @@
1
+ module UixValidations
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module UixValidations
2
+ VERSION = "0.5.1"
3
+ end
@@ -0,0 +1,38 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "uix_validations/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "uix_validations"
8
+ spec.version = UixValidations::VERSION
9
+ spec.authors = ["Lucas Andrade"]
10
+ spec.email = ["lucasandrad@yandex.com"]
11
+
12
+ spec.summary = %q{This gem provides real time validations for forms}
13
+ spec.description = %q{This gem provides real time validations for forms. All validations follow the best principles of UI and UX}
14
+ spec.homepage = "https://github.com/LucasAndrad/uix_validations"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ # Specify which files should be added to the gem when it is released.
27
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ spec.add_development_dependency "bundler", "~> 1.16"
36
+ spec.add_development_dependency "rake", "~> 10.0"
37
+ spec.add_runtime_dependency 'autoprefixer-rails', '~> 9.1', '>= 9.1.0'
38
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uix_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Andrade
@@ -66,8 +66,19 @@ executables: []
66
66
  extensions: []
67
67
  extra_rdoc_files: []
68
68
  files:
69
- - vendor/assets/javascripts/uix_validations.js
70
- - vendor/assets/stylesheets/uix_validations.scss
69
+ - ".gitignore"
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - app/assets/javascripts/uix_validations.js
75
+ - app/assets/stylesheets/uix_validations.scss
76
+ - bin/console
77
+ - bin/setup
78
+ - lib/uix_validations.rb
79
+ - lib/uix_validations/engine.rb
80
+ - lib/uix_validations/version.rb
81
+ - uix_validations.gemspec
71
82
  homepage: https://github.com/LucasAndrad/uix_validations
72
83
  licenses:
73
84
  - MIT