cmdx 1.5.0 → 1.5.1
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 +4 -4
- data/.cursor/rules/cursor-instructions.mdc +0 -1
- data/CHANGELOG.md +7 -0
- data/lib/cmdx/locale.rb +1 -1
- data/lib/cmdx/railtie.rb +1 -1
- data/lib/cmdx/validators/length.rb +11 -9
- data/lib/cmdx/validators/numeric.rb +9 -9
- data/lib/cmdx/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd6e2321faffcce3015989a0e58df96c87be1dbdc4755cc7b783546bc5ecbc4f
|
4
|
+
data.tar.gz: cc5f262ac3f329a308e8a0c25a0f200830830d09c3560c913f8a80ff5997aab8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71e5f8a864f91b10ca26985bfbd7502fcc751e70117562bee62f606f340468bd517e329a05de5f80d495ff7bb0aaf0195564ceaa95267b9bfdba6d3c424c0698
|
7
|
+
data.tar.gz: 2d560416d0838761e481952a5d759e05db859fef027e74a5c6c5bb65e49756ab041a35f7725d88ba40746b93f2726bee65e317b7c89d5e56291dd9767c99603f
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
|
7
7
|
## [TODO]
|
8
8
|
|
9
|
+
## [1.5.1] - 2025-08-21
|
10
|
+
|
11
|
+
### Changes
|
12
|
+
- Prefix I18n with `::` to play nice with `CMDx::I18n`
|
13
|
+
- Safe navigate length and numeric validators
|
14
|
+
- Update railtie file path points to correct directory
|
15
|
+
|
9
16
|
## [1.5.0] - 2025-08-21
|
10
17
|
|
11
18
|
### Changes
|
data/lib/cmdx/locale.rb
CHANGED
@@ -36,7 +36,7 @@ module CMDx
|
|
36
36
|
# # => "Custom fallback message"
|
37
37
|
def translate(key, **options)
|
38
38
|
options[:default] ||= EN.dig("en", *key.to_s.split("."))
|
39
|
-
return I18n.t(key, **options) if defined?(I18n)
|
39
|
+
return ::I18n.t(key, **options) if defined?(::I18n)
|
40
40
|
|
41
41
|
case message = options.delete(:default)
|
42
42
|
when NilClass then "Translation missing: #{key}"
|
data/lib/cmdx/railtie.rb
CHANGED
@@ -23,7 +23,7 @@ module CMDx
|
|
23
23
|
# # in the CMDx gem's locales directory
|
24
24
|
initializer("cmdx.configure_locales") do |app|
|
25
25
|
Array(app.config.i18n.available_locales).each do |locale|
|
26
|
-
path = CMDx.gem_path.join("locales/#{locale}.yml")
|
26
|
+
path = CMDx.gem_path.join("lib/locales/#{locale}.yml")
|
27
27
|
next unless File.file?(path)
|
28
28
|
|
29
29
|
I18n.load_path << path
|
@@ -52,25 +52,27 @@ module CMDx
|
|
52
52
|
# Length.call("short", not_in: 1..3)
|
53
53
|
# # => nil (validation passes - length 5 is not in excluded range)
|
54
54
|
def call(value, options = {})
|
55
|
+
length = value&.length
|
56
|
+
|
55
57
|
case options
|
56
58
|
in within:
|
57
|
-
raise_within_validation_error!(within.begin, within.end, options) unless within
|
59
|
+
raise_within_validation_error!(within.begin, within.end, options) unless within&.cover?(length)
|
58
60
|
in not_within:
|
59
|
-
raise_not_within_validation_error!(not_within.begin, not_within.end, options) if not_within
|
61
|
+
raise_not_within_validation_error!(not_within.begin, not_within.end, options) if not_within&.cover?(length)
|
60
62
|
in in: xin
|
61
|
-
raise_within_validation_error!(xin.begin, xin.end, options) unless xin
|
63
|
+
raise_within_validation_error!(xin.begin, xin.end, options) unless xin&.cover?(length)
|
62
64
|
in not_in:
|
63
|
-
raise_not_within_validation_error!(not_in.begin, not_in.end, options) if not_in
|
65
|
+
raise_not_within_validation_error!(not_in.begin, not_in.end, options) if not_in&.cover?(length)
|
64
66
|
in min:, max:
|
65
|
-
raise_within_validation_error!(min, max, options) unless
|
67
|
+
raise_within_validation_error!(min, max, options) unless length&.between?(min, max)
|
66
68
|
in min:
|
67
|
-
raise_min_validation_error!(min, options) unless min <=
|
69
|
+
raise_min_validation_error!(min, options) unless !length.nil? && (min <= length)
|
68
70
|
in max:
|
69
|
-
raise_max_validation_error!(max, options) unless
|
71
|
+
raise_max_validation_error!(max, options) unless !length.nil? && (length <= max)
|
70
72
|
in is:
|
71
|
-
raise_is_validation_error!(is, options) unless
|
73
|
+
raise_is_validation_error!(is, options) unless !length.nil? && (length == is)
|
72
74
|
in is_not:
|
73
|
-
raise_is_not_validation_error!(is_not, options) if
|
75
|
+
raise_is_not_validation_error!(is_not, options) if !length.nil? && (length == is_not)
|
74
76
|
else
|
75
77
|
raise ArgumentError, "unknown length validator options given"
|
76
78
|
end
|
@@ -51,23 +51,23 @@ module CMDx
|
|
51
51
|
def call(value, options = {})
|
52
52
|
case options
|
53
53
|
in within:
|
54
|
-
raise_within_validation_error!(within.begin, within.end, options) unless within
|
54
|
+
raise_within_validation_error!(within.begin, within.end, options) unless within&.cover?(value)
|
55
55
|
in not_within:
|
56
|
-
raise_not_within_validation_error!(not_within.begin, not_within.end, options) if not_within
|
56
|
+
raise_not_within_validation_error!(not_within.begin, not_within.end, options) if not_within&.cover?(value)
|
57
57
|
in in: xin
|
58
|
-
raise_within_validation_error!(xin.begin, xin.end, options) unless xin
|
58
|
+
raise_within_validation_error!(xin.begin, xin.end, options) unless xin&.cover?(value)
|
59
59
|
in not_in:
|
60
|
-
raise_not_within_validation_error!(not_in.begin, not_in.end, options) if not_in
|
60
|
+
raise_not_within_validation_error!(not_in.begin, not_in.end, options) if not_in&.cover?(value)
|
61
61
|
in min:, max:
|
62
|
-
raise_within_validation_error!(min, max, options) unless value
|
62
|
+
raise_within_validation_error!(min, max, options) unless value&.between?(min, max)
|
63
63
|
in min:
|
64
|
-
raise_min_validation_error!(min, options) unless min <= value
|
64
|
+
raise_min_validation_error!(min, options) unless !value.nil? && (min <= value)
|
65
65
|
in max:
|
66
|
-
raise_max_validation_error!(max, options) unless value <= max
|
66
|
+
raise_max_validation_error!(max, options) unless !value.nil? && (value <= max)
|
67
67
|
in is:
|
68
|
-
raise_is_validation_error!(is, options) unless value == is
|
68
|
+
raise_is_validation_error!(is, options) unless !value.nil? && (value == is)
|
69
69
|
in is_not:
|
70
|
-
raise_is_not_validation_error!(is_not, options) if value == is_not
|
70
|
+
raise_is_not_validation_error!(is_not, options) if !value.nil? && (value == is_not)
|
71
71
|
else
|
72
72
|
raise ArgumentError, "unknown numeric validator options given"
|
73
73
|
end
|
data/lib/cmdx/version.rb
CHANGED