ama_validators 0.0.6 → 0.0.7

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: 64029a3e49c71deed296020736920b6907e0d572
4
- data.tar.gz: 894448afc757c3165d1634f0011fa2974d05fb4a
3
+ metadata.gz: 1c9614a52d7db2277d72016cb12ce7d2a37f2243
4
+ data.tar.gz: c16272215b974ab584d9d5ddb2d581d5627219a4
5
5
  SHA512:
6
- metadata.gz: a9b49b334d61fc0f831328317cb21212020b2520be6e5bd5ecd5d276aa8b13cd2fa9d44945e792b0b33da363ab19ea83f205779a81d41941403773fc87e0d537
7
- data.tar.gz: 6ffae19b0cfa27123b2ed6e6a851caa2f1abb460cdcaaffea0b56325b1dca29bbd3a8da2a0ac2127461241b095fcb7b22b719b1df80f962dee67d9ac1f3d72f4
6
+ metadata.gz: 52ef9dcddbebe180317a6fee81b162309927cca12217e2029ee51200c660de39a8b5eb97bc51d54ee5086813ea3172a96aad4b663054bfcbbf839c5a4b840610
7
+ data.tar.gz: 82a782460d95064be8a77a1a96806c5178079988de3eeab5d9719f348bb49b70a8f02d63729aad1d946bbbd1f16d484af58ac4b408743d9a594ccd4226bf8979
@@ -3,12 +3,14 @@
3
3
 
4
4
  class ProvinceValidator < ActiveModel::EachValidator
5
5
  def validate_each(object, attribute, value)
6
- provinces = PROV_STATE[object.send(options[:country])]
6
+ provinces = PROV_STATE[object.send(options[:country]).to_sym]
7
7
  if !provinces.try(:include?, value)
8
- object.errors[attribute] << (options[:message] || 'Province/State is in selected country.')
8
+ object.errors[attribute] << (options[:message] || 'Province/State should be in selected country.')
9
9
  end
10
10
  end
11
11
 
12
+ COUNTRIES = { canada: 'Canada', usa: 'United States of America', mexico: 'Mexico' }
13
+
12
14
  PROV_STATE = {
13
15
  canada: ['Alberta', 'British Columbia', 'Manitoba', 'New Brunswick', 'Newfoundland', 'Nova Scotia',
14
16
  'Northwest Territories', 'Nunavut', 'Ontario', 'Prince Edward Island', 'Saskatchewan',
@@ -1,3 +1,3 @@
1
1
  module AmaValidators
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -11,6 +11,15 @@ describe ProvinceValidator do
11
11
 
12
12
  subject { Validatable.new({ country: country, province: province }) }
13
13
 
14
+ context 'province is in selected country as a string' do
15
+ let(:country) { 'canada' }
16
+ let(:province) { 'Alberta' }
17
+
18
+ it 'is valid' do
19
+ expect(subject).to be_valid
20
+ end
21
+ end
22
+
14
23
  context 'province is in selected country' do
15
24
  let(:country) { :canada }
16
25
  let(:province) { 'Alberta' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ama_validators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van den Beuken