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 +4 -4
- data/lib/mini_defender/handles_validation_errors.rb +1 -1
- data/lib/mini_defender/rules/currency.rb +23 -0
- data/lib/mini_defender/version.rb +1 -1
- data/mini_defender.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe54cbe51ddd477ec4d061e9d5f9a6aa0732021800ecbff7aef6f3baeb7325d6
|
4
|
+
data.tar.gz: a8186c65527cf020fb6f8433740a9c026e032cc440ed12c5823261217287c099
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/mini_defender.gemspec
CHANGED
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.
|
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-
|
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
|