simple_form 5.4.0 → 5.4.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/CHANGELOG.md +6 -1
- data/MIT-LICENSE +1 -1
- data/README.md +1 -1
- data/lib/simple_form/components/maxlength.rb +2 -1
- data/lib/simple_form/components/min_max.rb +4 -14
- data/lib/simple_form/components/minlength.rb +2 -1
- data/lib/simple_form/components/pattern.rb +1 -9
- data/lib/simple_form/helpers/validators.rb +21 -0
- data/lib/simple_form/version.rb +1 -1
- metadata +30 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9ab83cf1fd374f5f1b1a26fb73e903b03f286fd32640db3c67e7cf270529e36d
|
|
4
|
+
data.tar.gz: 6b73d95e3515adcf607dbfa9a93b3556cf9219b8a32c6540ee98b822c3e75b1a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5171360f4f381ba58c83a7d0f798770b7f9a90afd4eebd03a573ce2a48f352f3e9ebf1ec079152082fbe88a727b9f57f4cfc85b3ba5537f636a806b81aa298e4
|
|
7
|
+
data.tar.gz: 69a2e9865036691353286c66e785f11b1a0ba04acf2e9cf4ce701f35e54656db649c6f623b929d828553474cffece865109611690f730eeac1980646b51dcca4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
##
|
|
1
|
+
## 5.4.1
|
|
2
|
+
|
|
3
|
+
* Ruby 4.0 support (no changes required)
|
|
4
|
+
* Support procs on validators for minlength/maxlength, and improve validators logic across the board to match Rails [#1859](https://github.com/heartcombo/simple_form/pull/1859)
|
|
5
|
+
|
|
6
|
+
## 5.4.0
|
|
2
7
|
|
|
3
8
|
* Add support for Ruby 3.4 and Rails 7.2/8.0/8.1. (no changes required)
|
|
4
9
|
* Drop support for Rails < 7 and Ruby < 2.7.
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -1328,7 +1328,7 @@ If you have discovered a security related bug, please do NOT use the GitHub issu
|
|
|
1328
1328
|
## License
|
|
1329
1329
|
|
|
1330
1330
|
MIT License.
|
|
1331
|
-
Copyright 2020-
|
|
1331
|
+
Copyright 2020-CURRENT Rafael França, Carlos Antonio da Silva.
|
|
1332
1332
|
Copyright 2009-2019 Plataformatec.
|
|
1333
1333
|
|
|
1334
1334
|
The Simple Form logo is licensed under [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License](https://creativecommons.org/licenses/by-nc-nd/4.0/).
|
|
@@ -26,7 +26,8 @@ module SimpleForm
|
|
|
26
26
|
|
|
27
27
|
def maximum_length_value_from(length_validator)
|
|
28
28
|
if length_validator
|
|
29
|
-
length_validator.options[:is] || length_validator.options[:maximum]
|
|
29
|
+
value = length_validator.options[:is] || length_validator.options[:maximum]
|
|
30
|
+
resolve_validator_value(value)
|
|
30
31
|
end
|
|
31
32
|
end
|
|
32
33
|
end
|
|
@@ -19,33 +19,23 @@ module SimpleForm
|
|
|
19
19
|
|
|
20
20
|
def minimum_value(validator_options)
|
|
21
21
|
if integer? && validator_options.key?(:greater_than)
|
|
22
|
-
|
|
22
|
+
resolve_validator_value(validator_options[:greater_than]) + 1
|
|
23
23
|
else
|
|
24
|
-
|
|
24
|
+
resolve_validator_value(validator_options[:greater_than_or_equal_to])
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def maximum_value(validator_options)
|
|
29
29
|
if integer? && validator_options.key?(:less_than)
|
|
30
|
-
|
|
30
|
+
resolve_validator_value(validator_options[:less_than]) - 1
|
|
31
31
|
else
|
|
32
|
-
|
|
32
|
+
resolve_validator_value(validator_options[:less_than_or_equal_to])
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def find_numericality_validator
|
|
37
37
|
find_validator(:numericality)
|
|
38
38
|
end
|
|
39
|
-
|
|
40
|
-
def evaluate_numericality_validator_option(option)
|
|
41
|
-
if option.is_a?(Numeric)
|
|
42
|
-
option
|
|
43
|
-
elsif option.is_a?(Symbol)
|
|
44
|
-
object.send(option)
|
|
45
|
-
elsif option.respond_to?(:call)
|
|
46
|
-
option.call(object)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
39
|
end
|
|
50
40
|
end
|
|
51
41
|
end
|
|
@@ -26,7 +26,8 @@ module SimpleForm
|
|
|
26
26
|
|
|
27
27
|
def minimum_length_value_from(length_validator)
|
|
28
28
|
if length_validator
|
|
29
|
-
length_validator.options[:is] || length_validator.options[:minimum]
|
|
29
|
+
value = length_validator.options[:is] || length_validator.options[:minimum]
|
|
30
|
+
resolve_validator_value(value)
|
|
30
31
|
end
|
|
31
32
|
end
|
|
32
33
|
end
|
|
@@ -15,21 +15,13 @@ module SimpleForm
|
|
|
15
15
|
if pattern.is_a?(String)
|
|
16
16
|
pattern
|
|
17
17
|
elsif (pattern_validator = find_pattern_validator) && (with = pattern_validator.options[:with])
|
|
18
|
-
|
|
18
|
+
resolve_validator_value(with).source
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def find_pattern_validator
|
|
23
23
|
find_validator(:format)
|
|
24
24
|
end
|
|
25
|
-
|
|
26
|
-
def evaluate_format_validator_option(option)
|
|
27
|
-
if option.respond_to?(:call)
|
|
28
|
-
option.call(object)
|
|
29
|
-
else
|
|
30
|
-
option
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
25
|
end
|
|
34
26
|
end
|
|
35
27
|
end
|
|
@@ -40,6 +40,27 @@ module SimpleForm
|
|
|
40
40
|
def find_validator(kind)
|
|
41
41
|
attribute_validators.find { |v| v.kind == kind } if has_validators?
|
|
42
42
|
end
|
|
43
|
+
|
|
44
|
+
# Implements `ActiveModel::Validations::ResolveValue`, introduced by Rails 7.1.
|
|
45
|
+
# https://github.com/rails/rails/blob/v7.1.0/activemodel/lib/active_model/validations/resolve_value.rb
|
|
46
|
+
def resolve_validator_value(value)
|
|
47
|
+
case value
|
|
48
|
+
when Proc
|
|
49
|
+
if value.arity == 0
|
|
50
|
+
value.call
|
|
51
|
+
else
|
|
52
|
+
value.call(object)
|
|
53
|
+
end
|
|
54
|
+
when Symbol
|
|
55
|
+
object.send(value)
|
|
56
|
+
else
|
|
57
|
+
if value.respond_to?(:call)
|
|
58
|
+
value.call(object)
|
|
59
|
+
else
|
|
60
|
+
value
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
43
64
|
end
|
|
44
65
|
end
|
|
45
66
|
end
|
data/lib/simple_form/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple_form
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.4.
|
|
4
|
+
version: 5.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- José Valim
|
|
@@ -53,6 +53,20 @@ dependencies:
|
|
|
53
53
|
- - ">="
|
|
54
54
|
- !ruby/object:Gem::Version
|
|
55
55
|
version: '0'
|
|
56
|
+
- !ruby/object:Gem::Dependency
|
|
57
|
+
name: minitest
|
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - "<"
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '6'
|
|
63
|
+
type: :development
|
|
64
|
+
prerelease: false
|
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - "<"
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '6'
|
|
56
70
|
- !ruby/object:Gem::Dependency
|
|
57
71
|
name: rake
|
|
58
72
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -67,6 +81,20 @@ dependencies:
|
|
|
67
81
|
- - ">="
|
|
68
82
|
- !ruby/object:Gem::Version
|
|
69
83
|
version: '0'
|
|
84
|
+
- !ruby/object:Gem::Dependency
|
|
85
|
+
name: rdoc
|
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
- - ">="
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: '0'
|
|
91
|
+
type: :development
|
|
92
|
+
prerelease: false
|
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
94
|
+
requirements:
|
|
95
|
+
- - ">="
|
|
96
|
+
- !ruby/object:Gem::Version
|
|
97
|
+
version: '0'
|
|
70
98
|
description: Forms made easy!
|
|
71
99
|
email: heartcombo.oss@gmail.com
|
|
72
100
|
executables: []
|
|
@@ -164,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
164
192
|
- !ruby/object:Gem::Version
|
|
165
193
|
version: '0'
|
|
166
194
|
requirements: []
|
|
167
|
-
rubygems_version:
|
|
195
|
+
rubygems_version: 4.0.3
|
|
168
196
|
specification_version: 4
|
|
169
197
|
summary: Forms made easy!
|
|
170
198
|
test_files: []
|