mini_defender 0.3.13 → 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: 1fb38a701337253718887e5d325fbc353b15959d3dfb66401aca722175e407da
4
- data.tar.gz: 46dcb917d9d66e10344641313af7a498cac609c9e08369dfc617457e2e1706f6
3
+ metadata.gz: fe54cbe51ddd477ec4d061e9d5f9a6aa0732021800ecbff7aef6f3baeb7325d6
4
+ data.tar.gz: a8186c65527cf020fb6f8433740a9c026e032cc440ed12c5823261217287c099
5
5
  SHA512:
6
- metadata.gz: 5ccf6dfcf0503020f603f8afdd33644a1d13d73bd56f5fd58706895c76b7e0a0d792a3644472fad2083a2135c2c3fb682cbf610838e9f7c6908d606266d04317
7
- data.tar.gz: 99fa8973a9cf335861e6e6e7b0522897831c0f67b779c4816956552ec8fb5e3a52e71522c95c7794e26a5b6e0a8178a5a2db72801b772c1dbac657cc3f645df7
6
+ metadata.gz: a74aa29990ce862b5c08fa03d2f0e90cd418dd90be39865894dc730883486afe49656c37d336992595c60f8db4140ca6e305083ef351ef23024c38d3227f596c
7
+ data.tar.gz: 925d4433c41784ff0dce20dbc5ffed0f76766ec481fc9d4856b4099fe5b28e6ef41943b3a56bb9b0ef3d34842df37c828bb69713c6973c730a3d7f46e61a996d
@@ -11,7 +11,7 @@ module MiniDefender::HandlesValidationErrors
11
11
 
12
12
  def handle_validation_error(error)
13
13
  unless self.respond_to?(:respond_to)
14
- render json: { message: error.message, errors: error.errors }, status: :unprocessable_entity
14
+ return render json: { message: error.message, errors: error.errors }, status: :unprocessable_entity
15
15
  end
16
16
 
17
17
  respond_to do |format|
@@ -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.13"
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.13
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