Skip to content
Browse files

documentation

  • Loading branch information...
1 parent a377487 commit fda4b1804a2237d4440224924493b1ba055cc92e @amatsuda committed
Showing with 110 additions and 10 deletions.
  1. +100 −0 README.rdoc
  2. +10 −10 html5_validators.gemspec
View
100 README.rdoc
@@ -0,0 +1,100 @@
+= HTML5Validators
+
+Automatic client-side validation using HTML5 Form Validation
+
+
+== What is this?
+
+html5_validators is a gem/plugin for Rails 3 that enables client-side validation using ActiveModel + HTML5
+
+
+== Features
+
+* PresenceValidator => requried
+
+ Model:
+ class User
+ include ActiveModel::Validations
+ validates_presence_of :name
+ end
+
+ View:
+ <%= f.text_field :name %>
+
+ HTML:
+ <input id="user_name" name="user[name]" required="required" type="text" />
+
+ SPEC:
+ http://dev.w3.org/html5/spec/Overview.html#attr-input-requiredhttp://dev.w3.org/html5/spec/Overview.html#attr-input-required
+
+* LengthValidator => maxlength
+
+ Model:
+ class User
+ include ActiveModel::Validations
+ validates_length_of :name, :maximum => 5
+ end
+
+ View:
+ <%= f.text_field :name %>
+
+ HTML:
+ <input id="user_name" maxlength="5" name="user[name]" size="5" type="text" />
+
+ SPEC:
+ http://dev.w3.org/html5/spec/Overview.html#attr-input-maxlength
+
+* NumericalityValidator => max, min
+
+ Model:
+ class User
+ include ActiveModel::Validations
+ validates_numericality_of :age, :greater_than_or_equal_to => 20
+ end
+
+ View: (be sure to use number_field)
+ <%= f.number_field :age %>
+
+ HTML:
+ <input id="user_age" min="20" name="user[age]" size="30" type="number" />
+
+ SPEC:
+ http://dev.w3.org/html5/spec/Overview.html#attr-input-max
+ http://dev.w3.org/html5/spec/Overview.html#attr-input-min
+
+
+* And more (coming soon...?)
+
+
+== Supported versions
+
+* Ruby 1.8.7, 1.9.2, 1.9.3 (trunk)
+
+* Rails 3.0.x, 3.1.beta1, 3.1 (edge)
+
+* HTML5 compatible browsers
+
+
+== Installation
+
+Put this line into your Gemfile:
+ gem 'html5_validators'
+
+Then bundle:
+ % bundle
+
+
+== Notes
+
+When accessed by an HTML5 incompatible lagacy brwoser, these extra attributes will just be ignored.
+
+
+== Todo
+
+* specs
+* more validations
+
+
+== Copyright
+
+Copyright (c) 2011 Asakusa.rb. See LICENSE.txt for further details.
View
20 html5_validators.gemspec
@@ -1,21 +1,21 @@
# -*- encoding: utf-8 -*-
-$:.push File.expand_path("../lib", __FILE__)
-require "html5_validators/version"
+$:.push File.expand_path('../lib', __FILE__)
+require 'html5_validators/version'
Gem::Specification.new do |s|
- s.name = "html5_validators"
+ s.name = 'html5_validators'
s.version = Html5Validators::VERSION
s.platform = Gem::Platform::RUBY
- s.authors = ["TODO: Write your name"]
- s.email = ["TODO: Write your email address"]
- s.homepage = ""
- s.summary = %q{TODO: Write a gem summary}
- s.description = %q{TODO: Write a gem description}
+ s.authors = ['Akira Matsuda']
+ s.email = ['ronnie@dio.jp']
+ s.homepage = 'https://github.com/amatsuda/html5_validators'
+ s.summary = 'Automatic client side validation using HTML5 Form Validation'
+ s.description = 'A gem/plugin for Rails 3 that enables client-side validation using ActiveModel + HTML5'
- s.rubyforge_project = "html5_validators"
+ s.rubyforge_project = 'html5_validators'
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
- s.require_paths = ["lib"]
+ s.require_paths = ['lib']
end

0 comments on commit fda4b18

Please sign in to comment.
Something went wrong with that request. Please try again.