Skip to content

Commit 31408ae

Browse files
authored
Fix nil value issue with coercible floats (#30)
Fix nil crash issue with CoercibleType definition
1 parent 363e7d3 commit 31408ae

13 files changed

Lines changed: 28 additions & 3 deletions

File tree

.approvals

Whitespace-only changes.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
/tmp/
99
/bin/
1010
*.swp
11+
.approvals
1112
spec/examples.txt

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## Unreleased
88

9+
## [0.7.1] - 2022-03-04
10+
### Fixed
11+
- Float coercion: check for nil before coercion
12+
913
## [0.7.0] - 2022-02-25
1014
### Added
1115
- Lambda definitions can now be failed with custom error messages

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
definition (0.7.0)
4+
definition (0.7.1)
55
activesupport
66
i18n
77

lib/definition/types/type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def initialize(name, klass, &coerce)
1414
end
1515

1616
def conform(value)
17-
value = coerce.call(value) if coerce && !valid?(value)
17+
value = coerce.call(value) if value && coerce && !valid?(value)
1818

1919
try_conform(value)
2020
end

lib/definition/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Definition
4-
VERSION = "0.7.0"
4+
VERSION = "0.7.1"
55
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"": "<Definition::ConformError \n\t message: \"Is of type NilClass instead of Float\", \n\t json_pointer: \"/\">"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"": "<Definition::ConformError \n\t message: \"Is of type NilClass instead of Float\", \n\t json_pointer: \"/\">"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Is of type NilClass instead of Float
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Is of type NilClass instead of Float

0 commit comments

Comments
 (0)