midas-g_live_validator 1.0.5 → 1.0.6
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/History.txt +10 -5
- data/README.rdoc +6 -1
- data/g_live_validator.gemspec +2 -2
- data/lib/g_live_validator.rb +1 -1
- data/lib/g_live_validator/view_helpers.rb +22 -2
- data/rails_generators/live_validator_assets/templates/guilded.live_validator.js +7 -1
- data/rails_generators/live_validator_assets/templates/guilded.live_validator.min.js +1 -15
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,16 +1,21 @@
|
|
1
|
-
== 1.0.
|
1
|
+
== 1.0.6 2009-06-18
|
2
2
|
|
3
|
-
* Added
|
3
|
+
* Added code so that client side JavaScript does not add validations with if or except options.
|
4
|
+
|
5
|
+
|
6
|
+
== 1.0.5 2009-06-03
|
7
|
+
|
8
|
+
* Added the g_live_dynamic_validations view helper that works with dynamic validations gem.
|
4
9
|
|
5
10
|
|
6
11
|
== 1.0.4 2009-04-03
|
7
12
|
|
8
|
-
* Added support for InacvtiveRecord (http://github.com/midas/inactive_record/tree/master) validations
|
13
|
+
* Added support for InacvtiveRecord (http://github.com/midas/inactive_record/tree/master) validations.
|
9
14
|
|
10
15
|
|
11
16
|
== 1.0.3
|
12
17
|
|
13
|
-
* Updated JavaScript to keep a collection LiveValidation objects indexed by field name accessible in
|
18
|
+
* Updated JavaScript to keep a collection LiveValidation objects indexed by field name accessible in the g namespace.
|
14
19
|
|
15
20
|
|
16
21
|
== 1.0.1
|
@@ -19,4 +24,4 @@
|
|
19
24
|
|
20
25
|
== 0.0.1 2009-03-09
|
21
26
|
|
22
|
-
* Initial release
|
27
|
+
* Initial release.
|
data/README.rdoc
CHANGED
@@ -17,7 +17,7 @@ valdiations.
|
|
17
17
|
* Declare validations once in ActiveRecord model's. If JavaScript is enabled, the validation will happen live. Otherwise,
|
18
18
|
the validation will happen normally, with a submission to the server.
|
19
19
|
* The error message defined in the validation macro will be used in live validation
|
20
|
-
* The following
|
20
|
+
* The following ActiveRecord validations are currently implemented and working: validates_presence_of (:message),
|
21
21
|
validates_numericality_of (:less_than, :less_than_or_equal_to, :equal_to, :greater_than, :greater_then_or_equal_to,
|
22
22
|
:only_integer, :notANumberMessage, :notAnIntegerMessage, :wrongNumberMessage, :tooLowMessage, :tooHighMessage),
|
23
23
|
validates_length_of / validates_size_of (:maximum, :minimum, :is, :within, :in, :too_long, :too_short, :wrong_length),
|
@@ -46,6 +46,11 @@ Make a call to the view_helper within a form:
|
|
46
46
|
|
47
47
|
<%= g_live_validator f %> # where f is the form variable passed into the form_for block
|
48
48
|
|
49
|
+
To use with a library like midas-dynamic_Validations, that does not use ActiveRecord validations, but some other method of
|
50
|
+
defining validations:
|
51
|
+
|
52
|
+
<%= g_live_dynamic_validator f, @validation_definitions %>
|
53
|
+
|
49
54
|
|
50
55
|
== OPTIONS:
|
51
56
|
|
data/g_live_validator.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{g_live_validator}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.6"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["C. Jason Harrelson (midas)"]
|
9
|
-
s.date = %q{2009-06-
|
9
|
+
s.date = %q{2009-06-18}
|
10
10
|
s.description = %q{Live validator is a Rails Guilded (http://github.com/midas/guilded/tree/master) component that will reflect ActiveRecord validations and use them to live validate forms. Live validator uses the Live Validation (http://www.livevalidation.com) JavaScript library to accomplish this task. It also uses an ActiveRecord extension authored by Michael Schuerig to mre easily reflect on the ActiveRecord valdiations.}
|
11
11
|
s.email = ["jason@lookforwardenterprises.com"]
|
12
12
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc"]
|
data/lib/g_live_validator.rb
CHANGED
@@ -28,10 +28,10 @@ module GLiveValidator
|
|
28
28
|
# validates_exclusion_of - :message
|
29
29
|
#
|
30
30
|
# If you need to do custom initialization you can implement g.beforeLiveValidatorInit() or
|
31
|
-
# g.afterLiveValidatorInit().
|
31
|
+
# g.afterLiveValidatorInit() in the client side JavaScript environment.
|
32
32
|
#
|
33
33
|
# If you need custom handling of valid or invalid fields, you can implement g.liveValidatorInvalidField()
|
34
|
-
# or g.
|
34
|
+
# or g.liveValidatorValidField() in the client side JavaScript environment.
|
35
35
|
#
|
36
36
|
# *parameters*
|
37
37
|
# form:: The form object from the form_for helper.
|
@@ -58,6 +58,26 @@ module GLiveValidator
|
|
58
58
|
return ""
|
59
59
|
end
|
60
60
|
|
61
|
+
# Guilded component. The live dynamic validator accepts an array of ValidationDefinition objects and
|
62
|
+
# sets up the live validations accordingly. This makes the live dynamic validator usable with the
|
63
|
+
# midas-dynamic_validations gem and possibly other validations that can be standardized through the
|
64
|
+
# ValidationDefinition object.
|
65
|
+
#
|
66
|
+
# The same validations that are supported by the g_live_validator are also supported.
|
67
|
+
#
|
68
|
+
# If you need to do custom initialization you can implement g.beforeLiveValidatorInit() or
|
69
|
+
# g.afterLiveValidatorInit() in the client side JavaScript environment.
|
70
|
+
#
|
71
|
+
# If you need custom handling of valid or invalid fields, you can implement g.liveValidatorInvalidField()
|
72
|
+
# or g.liveValidatorValidField() in the client side JavaScript environment.
|
73
|
+
#
|
74
|
+
# *parameters*
|
75
|
+
# form:: The form object from the form_for helper.
|
76
|
+
#
|
77
|
+
# *options*
|
78
|
+
# id:: (required)
|
79
|
+
# except:: List of fields to not include. A string, symbol or array of strings or symbols.
|
80
|
+
#
|
61
81
|
def g_live_dynamic_validator( form, validation_rules, *args )
|
62
82
|
options = args.extract_options!
|
63
83
|
klass = form.object.class
|
@@ -7,6 +7,7 @@ g.liveValidations = []; /* The collection of live validation objects */
|
|
7
7
|
|
8
8
|
g.doInvalidField = function()
|
9
9
|
{
|
10
|
+
// If the invalid field method is implemented
|
10
11
|
if( g.liveValidatorInvalidField )
|
11
12
|
{
|
12
13
|
g.liveValidatorInvalidField( this );
|
@@ -20,6 +21,7 @@ g.doInvalidField = function()
|
|
20
21
|
|
21
22
|
g.doValidField = function()
|
22
23
|
{
|
24
|
+
// If the valid field method is implemented
|
23
25
|
if( g.liveValidatorValidField )
|
24
26
|
g.liveValidatorValidField( this );
|
25
27
|
else
|
@@ -73,7 +75,11 @@ g.liveValidatorInit = function( options )
|
|
73
75
|
for( var i=0; i<vList.length; i++ )
|
74
76
|
{
|
75
77
|
var validation = vList[i];
|
76
|
-
|
78
|
+
if( validation.args == null || ( validation.args['if'] == null && validation.args['except'] == null ) )
|
79
|
+
{
|
80
|
+
v.add( validationMethods[ validation.name ], validation.args );
|
81
|
+
}
|
82
|
+
|
77
83
|
g.liveValidationsByField[field] = v;
|
78
84
|
g.liveValidations.push( v );
|
79
85
|
}
|
@@ -1,18 +1,4 @@
|
|
1
1
|
/* Guilded Live Validator 1.0.1
|
2
2
|
* Copyright (c) 2009 C. Jason Harrelson (midas)
|
3
3
|
* Guilded Live Validator is licensed under the terms of the MIT License */
|
4
|
-
g.doInvalidField=function()
|
5
|
-
{if(g.liveValidatorInvalidField)
|
6
|
-
{g.liveValidatorInvalidField(this);}
|
7
|
-
else
|
8
|
-
{this.insertMessage(this.createMessageSpan());this.addFieldClass();}};g.doValidField=function()
|
9
|
-
{if(g.liveValidatorValidField)
|
10
|
-
g.liveValidatorValidField(this);else
|
11
|
-
{this.insertMessage(this.createMessageSpan());this.addFieldClass();}};g.liveValidatorInit=function(options)
|
12
|
-
{if(g.beforeLiveValidatorInit)
|
13
|
-
g.beforeLiveValidatorInit(options);var moreValidationMethods={presence:Validate.Presence,numericality:Validate.Numericality,format:Validate.Format,length:Validate.Length,acceptance:Validate.Acceptance,confirmation:Validate.Confirmation};var validationMethods={validates_presence_of:Validate.Presence,validates_numericality_of:Validate.Numericality,validates_format_of:Validate.Format,validates_length_of:Validate.Length,validates_size_of:Validate.Length,validates_acceptance_of:Validate.Acceptance,validates_confirmation_of:Validate.Confirmation,validates_inclusion_of:Validate.Inclusion,validates_exclusion_of:Validate.Exclusion};var validations=options['validations'];for(field in validations)
|
14
|
-
{fieldEl=$j('#'+field);if(fieldEl.length==0)
|
15
|
-
continue;var vList=validations[field];var v=null;v=new LiveValidation(field,{onlyOnBlur:true,onInvalid:g.doInvalidField,onValid:g.doValidField});for(var i=0;i<vList.length;i++)
|
16
|
-
{var validation=vList[i];v.add(validationMethods[validation.name],validation.args);}}
|
17
|
-
if(g.afterLiveValidatorInit)
|
18
|
-
g.afterLiveValidatorInit(options);};
|
4
|
+
g.liveValidationsByField={};g.liveValidations=[];g.doInvalidField=function(){if(g.liveValidatorInvalidField){g.liveValidatorInvalidField(this)}else{this.insertMessage(this.createMessageSpan());this.addFieldClass()}};g.doValidField=function(){if(g.liveValidatorValidField)g.liveValidatorValidField(this);else{this.insertMessage(this.createMessageSpan());this.addFieldClass()}};g.liveValidatorInit=function(options){if(g.beforeLiveValidatorInit)g.beforeLiveValidatorInit(options);var moreValidationMethods={presence:Validate.Presence,numericality:Validate.Numericality,format:Validate.Format,length:Validate.Length,acceptance:Validate.Acceptance,confirmation:Validate.Confirmation};var validationMethods={validates_presence_of:Validate.Presence,validates_numericality_of:Validate.Numericality,validates_format_of:Validate.Format,validates_length_of:Validate.Length,validates_size_of:Validate.Length,validates_acceptance_of:Validate.Acceptance,validates_confirmation_of:Validate.Confirmation,validates_inclusion_of:Validate.Inclusion,validates_exclusion_of:Validate.Exclusion};var validations=options['validations'];for(field in validations){fieldEl=$j('#'+field);if(fieldEl.length==0)continue;var vList=validations[field];var v=null;v=new LiveValidation(field,{onlyOnBlur:true,onInvalid:g.doInvalidField,onValid:g.doValidField});for(var i=0;i<vList.length;i++){var validation=vList[i];if(validation.args==null||(validation.args['if']==null&&validation.args['except']==null)){v.add(validationMethods[validation.name],validation.args)}g.liveValidationsByField[field]=v;g.liveValidations.push(v)}}if(g.afterLiveValidatorInit)g.afterLiveValidatorInit(options)};
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: midas-g_live_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- C. Jason Harrelson (midas)
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-18 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|