rails_validations 1.1.1 → 1.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca94580d4d2e98cbf041af91b800f16ddbf00510
4
- data.tar.gz: 08b0d19a8afb7578b6304803f0e58833f3fdfe92
3
+ metadata.gz: fc1dd77a7c0210226a3a1d51326400739d74839b
4
+ data.tar.gz: a6d84e924ef157d550e5a1d560eebb69d6801902
5
5
  SHA512:
6
- metadata.gz: 36e62bff1d8386a26e4a9791d40d88e7d9e46588bfec526eae1ec29da3dd0acb952ab1af95ac759f1354bd14b21d37d1385e279f2f2e52bd32a089a5afbd640f
7
- data.tar.gz: 85b6b3f4a22432c73b4bd3e7e282e7ea512f0b8629562fe56205dd2d326a23b00461887c1620beddf6a1d7a820186e15670add9419b06b9774de2c034f1d25f2
6
+ metadata.gz: 354295b2cd7f84d48ac1cc619da220cf79ae65205f876118da20bb626fa69f8304d3808836ebc6dcbeb012c165417cceedddf3282bbe8234a7a373d6eaa38d02
7
+ data.tar.gz: 05fd3b1468787d6252cc663b0fafe84ed6986142133cb523f755bc9d8aabba9661651e3efaacff55eff9cb0b7c5bdc055da629b811e34ba36162e42a03928cf6
data/README.markdown CHANGED
@@ -1,10 +1,24 @@
1
- A few extra validations for rails.
1
+ [![Gem Version](https://badge.fury.io/rb/rails_validations.svg)](http://badge.fury.io/rb/rails_validations)
2
+ [![Build Status](https://travis-ci.org/bluerail/rails_validations.svg)](https://travis-ci.org/bluerail/rails_validations)
3
+ [![Dependency Status](https://gemnasium.com/bluerail/rails_validations.svg)](https://gemnasium.com/bluerail/rails_validations)
4
+ [![Inline docs](http://inch-ci.org/github/bluerail/rails_validations.svg?branch=master)](http://inch-ci.org/github/bluerail/rails_validations)
5
+
6
+
7
+ A few extra validations for Rails.
8
+
9
+ We try to do the ‘sane’ thing by not being too strict, when in doubt, we accept
10
+ input as being valid. We never want to reject valid input as invalid.
11
+
12
+ For many formats doing a 100% foolproof check is not trivial, email addresses
13
+ are a famous example, but it also applies to other formats.
14
+ Regardless, you can never be sure it’s what the user *intended* anyway. For
15
+ example, email validators will accept `artin@ico.nl` as being ‘valid’, even
16
+ though my email address is `martin@lico.nl.`.
2
17
 
3
- [RubyGems.org entry](http://rubygems.org/gems/rails_validations)
4
18
 
5
19
  date
6
20
  ----
7
- Validate if a column is a valid date, and if it's before or after another date.
21
+ Validate if a column is a valid date, and if its before or after another date.
8
22
 
9
23
  validates :date_column, date: true
10
24
  validates :date_column, date: { after: Date.today }
@@ -13,28 +27,36 @@ Validate if a column is a valid date, and if it's before or after another date.
13
27
  validates :date_column, date: { before: Date.today }
14
28
  validates :date_column, date: { before_or_equal_to: Date.today }
15
29
 
16
- # Check if the column `enddate` is after the value of the column `begindate`
30
+ Check if the column `enddate` is after the value of the column `begindate`:
31
+
17
32
  validates :begindate, date: true
18
33
  validates :enddate, date: { after: :begindate }
19
34
 
20
35
 
21
36
  domain
22
37
  ------
23
- Validate if a string is a valid domain. This should work with [IDN](idn).
38
+ Validate if a string looks like a valid domain. This should work with [IDN](idn).
39
+
40
+ This will accept `lico.nl`, but rejects `martin@lico.nl`:
24
41
 
25
42
  validates :domain_column, domain: true
26
43
 
27
- # Set a minimum/maximum number of domain parts (aka. labels)
44
+ Set a minimum/maximum number of domain parts (aka. labels), this will accept
45
+ `lico.nl`, but rejects `lico`:
46
+
28
47
  validates :domain_column, domain: { min_domain_parts: 2 }
48
+
49
+ Accept `lico.nl`, but reject `www.lico.nl`:
50
+
29
51
  validates :domain_column, domain: { max_domain_parts: 2 }
30
52
 
31
53
 
32
54
  email
33
55
  -----
34
- Do a basic checks for emails. Not that this check is *not* very strict, it is
35
- nigh-impossible to check if an email address is valid (and even if it is, it's
36
- no guarantee if emails actually gets delivered to this address). This should
37
- work with unicode addresses ([RFC 6531][rfc6531], [IDN][idn]).
56
+ Validate if a string looks liek an email address. This should work with unicode
57
+ addresses ([RFC 6531][rfc6531], [IDN][idn]).
58
+
59
+ Accepts `martin@lico.nl`, but rejects `martinlico.nl` or `martin@lico`
38
60
 
39
61
  validates :email_column, email: true
40
62
 
@@ -49,8 +71,10 @@ Check if this is a valid IBAN account number. This uses the
49
71
 
50
72
  phone
51
73
  -----
52
- Check if this is a valid phone number. As with the Email check, this isn't
53
- particularly strict; conventions for writing phone numbers vary a lot.
74
+ Check if this is a valid phone number. This should work with most, if not all,
75
+ writing conventions. We consider a phone to be valid if it consists of numbers &
76
+ any number of ` \-.()`; a country code at the start indicated with `+` is also
77
+ accepted.
54
78
 
55
79
  validates :phone_column, phone: true
56
80
 
@@ -73,10 +97,17 @@ Currently implemented countries:
73
97
  ChangeLog
74
98
  =========
75
99
 
100
+ version 1.1.2, 20141201
101
+ -----------------------
102
+ - Fix typo in Dutch translation.
103
+ - Update some docs.
104
+
105
+
76
106
  version 1.1.1, 20141013
77
107
  -----------------------
78
- - Fix i18n key for `phone`
79
- - Allow passing a Proc to `date` without an argument
108
+ - Fix i18n key for `phone`.
109
+ - Allow passing a Proc to `date` without an argument.
110
+
80
111
 
81
112
  version 1.1, 20141003
82
113
  ---------------------
@@ -1,7 +1,7 @@
1
1
  nl:
2
2
  rails_validations:
3
3
  email:
4
- invalid: geen geldig E-mailaddress
4
+ invalid: geen geldig e-mailaddress
5
5
 
6
6
  date:
7
7
  invalid: geen geldige datum
@@ -1,3 +1,15 @@
1
+ # Validate if a column is a valid date, and if it's before or after another date.
2
+ #
3
+ # validates :date_column, date: true
4
+ # validates :date_column, date: { after: Date.today }
5
+ # validates :date_column, date: { after_or_equal_to: Date.today }
6
+ # validates :date_column, date: { equal_to: Date.today }
7
+ # validates :date_column, date: { before: Date.today }
8
+ # validates :date_column, date: { before_or_equal_to: Date.today }
9
+ #
10
+ # Check if the column `enddate` is after the value of the column `begindate`
11
+ # validates :begindate, date: true
12
+ # validates :enddate, date: { after: :begindate }
1
13
  class DateValidator < ActiveModel::EachValidator
2
14
  CHECKS = {
3
15
  # These keys make the most sense for dates
@@ -1,3 +1,11 @@
1
+ # Validate if a string is a valid domain. This should work with [IDN](idn).
2
+ #
3
+ # validates :domain_column, domain: true
4
+ #
5
+ # Set a minimum/maximum number of domain parts (aka. labels)
6
+ #
7
+ # validates :domain_column, domain: { min_domain_parts: 2 }
8
+ # validates :domain_column, domain: { max_domain_parts: 2 }
1
9
  class DomainValidator < ActiveModel::EachValidator
2
10
  #\A[a-zA-Z\d-]{,63}\z
3
11
  REGEXP = /
@@ -1,5 +1,5 @@
1
+ # Check if this is a valid IBAN number; we use the +iban_tools+ gem for this.
1
2
  class IbanValidator < ActiveModel::EachValidator
2
-
3
3
  def validate_each record, attribute, value
4
4
  require 'iban-tools'
5
5
 
@@ -1,3 +1,5 @@
1
+ # Basic check for a telephone number; this should work with most, of not all,
2
+ # writing conventions.
1
3
  class PhoneValidator < ActiveModel::EachValidator
2
4
  REGEXP = /\A
3
5
  (\(?\+\d+\)?)? # optional country code
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Tournoij
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-13 00:00:00.000000000 Z
11
+ date: 2014-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: iban-tools
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-rails
57
57
  requirement: !ruby/object:Gem::Requirement