has_validated_attributes 0.0.1 → 0.0.2
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/Gemfile +1 -1
- data/lib/has_validated_attributes.rb +10 -10
- data/lib/version.rb +1 -1
- metadata +1 -1
data/Gemfile
CHANGED
@@ -12,7 +12,7 @@ module HasValidatedAttributes
|
|
12
12
|
opts.each{|k,v| validation.merge!(:length => {k.to_s.split("_").first.to_sym => v});options.delete(k)} if opts.present?
|
13
13
|
### extra options ###
|
14
14
|
validation.merge!(options) if options.present?
|
15
|
-
|
15
|
+
|
16
16
|
format.merge(validation)
|
17
17
|
end
|
18
18
|
end
|
@@ -21,18 +21,18 @@ module HasValidatedAttributes
|
|
21
21
|
#loading all methods dynamically
|
22
22
|
validations :name => {:format => {:with => /\A[^[:cntrl:]\\<>]*\z/, :message => "avoid non-printing characters and \\></ please."}, :length => {:maximum => 63}, :has_if? => true},
|
23
23
|
:username => {:length => {:within => 5..127}, :format => {:with => /\A\w[\w\.\-_@]+\z/, :message => "use only letters, numbers, and .-_@ please."}, :uniqueness => true},
|
24
|
-
:rails_name => {:format => {:with =>
|
24
|
+
:rails_name => {:format => {:with => /\A[a-zA-Z\_]*?\z/u, :message => "should only include underscores and letters."}},
|
25
25
|
:email => {:length => {:maximum => 63}, :format => {:with => /\A[\w\.%\+\-]+@(?:[A-Z0-9\-]+\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|pro|mobi|name|aero|jobs|museum)\z/i, :message => "should look like an email address."}},
|
26
|
-
:phone_number => {:numericality => {:greater_than_or_equal_to => 1000000000, :less_than => 10000000000, :message => 'accepts only 10 numbers and (),.- characters'}, :has_if? => true},
|
26
|
+
:phone_number => {:numericality => {:greater_than_or_equal_to => 1000000000, :less_than => 10000000000, :message => 'accepts only 10 numbers and (),.- characters and must not be all 0s'}, :has_if? => true},
|
27
27
|
:phone_extension => {:numericality => {:greater_than_or_equal_to => 0, :less_than => 100000000, :message => 'accepts only numbers (0-9)'}, :has_if? => true},
|
28
28
|
:domain => {:length => {:maximum => 63}, :format => {:with => /\A(?:[A-Z0-9\-]+\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|pro|mobi|name|aero|jobs|museum)\z/i, :message => "should look like a domain name."}},
|
29
|
-
:zipcode => {:format => {:with =>
|
30
|
-
:middle_initial => {:format => {:with =>
|
31
|
-
:dollar => {:format => {:with =>
|
32
|
-
:positive_dollar => {:format => {:with =>
|
33
|
-
:percent => {:format => {:with =>
|
34
|
-
:positive_percent => {:format => {:with =>
|
35
|
-
:url => {:length => {:maximum => 255}, :format => {:with =>
|
29
|
+
:zipcode => {:format => {:with => /\A\d{5}(\d{4})?\z/, :message => "must contain 5 or 9 numbers"}, :has_if? => true},
|
30
|
+
:middle_initial => {:format => {:with => /\A[a-zA-Z]{0,1}\z/u, :message => "accepts only one letter"}},
|
31
|
+
:dollar => {:format => {:with => /\A-?[0-9]{0,12}(\.[0-9]{0,2})?\z/, :message => "accepts only numeric characters, period, and negative sign"}, :numericality => {:greater_than => -1000000000000, :less_than => 1000000000000}, :allow_nil => true},
|
32
|
+
:positive_dollar => {:format => {:with => /\A[0-9]{0,12}(\.[0-9]{0,2})?\z/, :message => "accepts only numeric characters, period"}, :numericality => {:greater_than_or_equal_to => 0, :less_than => 1000000000000}, :allow_nil => true},
|
33
|
+
:percent => {:format => {:with => /\A-?[0-9]{0,3}(\.[0-9]{0,3})?\z/, :message => "accepts only numeric characters, period, negative sign, and must be equal/less/greater than +/- 100"}},
|
34
|
+
:positive_percent => {:format => {:with => /\A[0-9]{0,3}(\.[0-9]{0,3})?\z/, :message => "accepts only numeric characters, period, and must be less than 100"}, :numericality => {:greater_than_or_equal_to => 0, :less_than_or_equal_to => 100}, :allow_nil => true},
|
35
|
+
:url => {:length => {:maximum => 255}, :format => {:with => /\A(http|https|ftp):\/\/[A-Z0-9]+([\.]{1}[a-z0-9-]{1,63})*\.[a-zA-Z]{2,5}(:[0-9]{1,5})?(\/.*)?\z/ix, :message => "web address isnt valid"}, :has_if? => true},
|
36
36
|
:social_security_number => {:length => {:is => 9}, :numericality => {:greater_than_or_equal_to => 0, :less_than => 1000000000, :message => "must be in the format 111-11-1111"}, :has_if? => true},
|
37
37
|
:taxid => {:length => {:is => 9}, :numericality => {:greater_than_or_equal_to => 9999999, :less_than => 1000000000, :message => "must be in the format 11-1111111"}, :has_if? => true},
|
38
38
|
:age => {:numericality => {:greater_than_or_equal_to => 0, :less_than_or_equal_to => 110, :message => 'must contain only 3 numbers and less than 110'}},
|
data/lib/version.rb
CHANGED