mini_defender 0.3.14 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f4bd21f8f4dcb876d1a925f4e7085ef98dfcbed4617c74c03e4397f8e82fdf7
4
- data.tar.gz: 9468125261910912a6e3934852e9045542fddf0c160bb8799cbb1bb14af02b4f
3
+ metadata.gz: fe54cbe51ddd477ec4d061e9d5f9a6aa0732021800ecbff7aef6f3baeb7325d6
4
+ data.tar.gz: a8186c65527cf020fb6f8433740a9c026e032cc440ed12c5823261217287c099
5
5
  SHA512:
6
- metadata.gz: b21ab061c620d5b3548cc50910511391d5ba5121f40338be876a00d09900904d41f04cd8c23fea1ea28a493f24c77dd19598499e10ef6f7169ffc3773037aeca
7
- data.tar.gz: f07bd0c875a71679046e76ebcce28d878b47a942112a8c4a184bc9a10f1406459c8c1e17b72dc175c86df24ed59848fcf045dc67099c86b633b6c27e6aa87ae8
6
+ metadata.gz: a74aa29990ce862b5c08fa03d2f0e90cd418dd90be39865894dc730883486afe49656c37d336992595c60f8db4140ca6e305083ef351ef23024c38d3227f596c
7
+ data.tar.gz: 925d4433c41784ff0dce20dbc5ffed0f76766ec481fc9d4856b4099fe5b28e6ef41943b3a56bb9b0ef3d34842df37c828bb69713c6973c730a3d7f46e61a996d
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'countries'
4
+
5
+ class MiniDefender::Rules::Currency < MiniDefender::Rule
6
+ CURRENCIES = Money::Currency.map(&:iso_code).map(&:upcase).uniq
7
+
8
+ def self.signature
9
+ 'currency'
10
+ end
11
+
12
+ def coerce(value)
13
+ value.strip.upcase
14
+ end
15
+
16
+ def passes?(attribute, value, validator)
17
+ value.is_a?(String) && CURRENCIES.include?(value.strip.upcase)
18
+ end
19
+
20
+ def message(attribute, value, validator)
21
+ 'The value must be a valid ISO-4217 currency code.'
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniDefender
4
- VERSION = "0.3.14"
4
+ VERSION = "0.4.0"
5
5
  end
@@ -34,4 +34,5 @@ Gem::Specification.new do |spec|
34
34
  spec.add_runtime_dependency 'activemodel', '>= 6.0'
35
35
  spec.add_runtime_dependency 'actionpack', '>= 6.0'
36
36
  spec.add_runtime_dependency 'countries'
37
+ spec.add_runtime_dependency 'money'
37
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_defender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.14
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Alhoshaiyan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-16 00:00:00.000000000 Z
11
+ date: 2023-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: money
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: A small and efficient validation library for Rails and anything that
70
84
  uses Ruby.
71
85
  email:
@@ -99,6 +113,7 @@ files:
99
113
  - lib/mini_defender/rules/confirmed.rb
100
114
  - lib/mini_defender/rules/country_code.rb
101
115
  - lib/mini_defender/rules/credit_card.rb
116
+ - lib/mini_defender/rules/currency.rb
102
117
  - lib/mini_defender/rules/date.rb
103
118
  - lib/mini_defender/rules/date_eq.rb
104
119
  - lib/mini_defender/rules/date_format.rb