html5_validators 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Akira Matsuda
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -10,7 +10,7 @@ html5_validators is a gem/plugin for Rails 3 that enables client-side validation
|
|
10
10
|
|
11
11
|
== Features
|
12
12
|
|
13
|
-
|
13
|
+
=== PresenceValidator => requried
|
14
14
|
|
15
15
|
Model:
|
16
16
|
class User
|
@@ -20,6 +20,7 @@ html5_validators is a gem/plugin for Rails 3 that enables client-side validation
|
|
20
20
|
|
21
21
|
View:
|
22
22
|
<%= f.text_field :name %>
|
23
|
+
other text_fieldish helpers, text_area, radio_button, and check_box are also available
|
23
24
|
|
24
25
|
HTML:
|
25
26
|
<input id="user_name" name="user[name]" required="required" type="text" />
|
@@ -27,10 +28,10 @@ html5_validators is a gem/plugin for Rails 3 that enables client-side validation
|
|
27
28
|
SPEC:
|
28
29
|
http://dev.w3.org/html5/spec/Overview.html#attr-input-required
|
29
30
|
|
30
|
-
|
31
|
-
http://img.skitch.com/
|
31
|
+
SCREENSHOTS:
|
32
|
+
http://img.skitch.com/20110517-8sagqrkjnmkinapmcc5tduy2b8.jpg
|
32
33
|
|
33
|
-
|
34
|
+
=== LengthValidator => maxlength
|
34
35
|
|
35
36
|
Model:
|
36
37
|
class User
|
@@ -47,7 +48,7 @@ http://img.skitch.com/20110516-1kmy7fcuwkq84xihki2udkgh3a.jpg
|
|
47
48
|
SPEC:
|
48
49
|
http://dev.w3.org/html5/spec/Overview.html#attr-input-maxlength
|
49
50
|
|
50
|
-
|
51
|
+
=== NumericalityValidator => max, min
|
51
52
|
|
52
53
|
Model:
|
53
54
|
class User
|
@@ -103,4 +104,4 @@ When accessed by an HTML5 incompatible lagacy browser, these extra attributes wi
|
|
103
104
|
|
104
105
|
== Copyright
|
105
106
|
|
106
|
-
Copyright (c) 2011 Asakusa.rb. See LICENSE
|
107
|
+
Copyright (c) 2011 Asakusa.rb. See MIT-LICENSE for further details.
|
@@ -10,8 +10,31 @@ module ActionView
|
|
10
10
|
end
|
11
11
|
to_input_field_tag_without_html5_attributes field_type, options
|
12
12
|
end
|
13
|
-
|
14
13
|
alias_method_chain :to_input_field_tag, :html5_attributes
|
14
|
+
|
15
|
+
def to_text_area_tag_with_html5_attributes(options = {})
|
16
|
+
if object.class.ancestors.include?(ActiveModel::Validations)
|
17
|
+
options["required"] ||= object.class.attribute_required?(method_name)
|
18
|
+
end
|
19
|
+
to_text_area_tag_without_html5_attributes options
|
20
|
+
end
|
21
|
+
alias_method_chain :to_text_area_tag, :html5_attributes
|
22
|
+
|
23
|
+
def to_radio_button_tag_with_html5_attributes(tag_value, options = {})
|
24
|
+
if object.class.ancestors.include?(ActiveModel::Validations)
|
25
|
+
options["required"] ||= object.class.attribute_required?(method_name)
|
26
|
+
end
|
27
|
+
to_radio_button_tag_without_html5_attributes tag_value, options
|
28
|
+
end
|
29
|
+
alias_method_chain :to_radio_button_tag, :html5_attributes
|
30
|
+
|
31
|
+
def to_check_box_tag_with_html5_attributes(options = {}, checked_value = "1", unchecked_value = "0")
|
32
|
+
if object.class.ancestors.include?(ActiveModel::Validations)
|
33
|
+
options["required"] ||= object.class.attribute_required?(method_name)
|
34
|
+
end
|
35
|
+
to_check_box_tag_without_html5_attributes options, checked_value, unchecked_value
|
36
|
+
end
|
37
|
+
alias_method_chain :to_check_box_tag, :html5_attributes
|
15
38
|
end
|
16
39
|
end
|
17
40
|
end
|
@@ -12,6 +12,12 @@ module ActiveModel
|
|
12
12
|
|
13
13
|
super
|
14
14
|
end
|
15
|
+
|
16
|
+
def validate_each_with_default_tokenizer(record, attribute, value)
|
17
|
+
@options = (options || {}).reverse_merge(:tokenizer => DEFAULT_TOKENIZER).freeze
|
18
|
+
validate_each_without_default_tokenizer record, attribute, value
|
19
|
+
end
|
20
|
+
alias_method_chain :validate_each, :default_tokenizer
|
15
21
|
end
|
16
22
|
|
17
23
|
class NumericalityValidator
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.2
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Akira Matsuda
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-17 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: A gem/plugin for Rails 3 that enables client-side validation using ActiveModel + HTML5
|
@@ -30,6 +30,7 @@ extra_rdoc_files: []
|
|
30
30
|
files:
|
31
31
|
- .gitignore
|
32
32
|
- Gemfile
|
33
|
+
- MIT-LICENSE
|
33
34
|
- README.rdoc
|
34
35
|
- Rakefile
|
35
36
|
- html5_validators.gemspec
|