Skip to content

Commit

Permalink
Merge pull request #216 from JordonPhillips/minmax
Browse files Browse the repository at this point in the history
Allow min to equal max in range
  • Loading branch information
JordonPhillips authored Nov 26, 2019
2 parents 3829739 + 68f75ee commit 32c5a03
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ private List<ValidationEvent> validateRangeTrait(Model model, Shape shape, Range
// Makes sure that `min` is less than `max`
trait.getMin()
.flatMap(min -> trait.getMax().map(max -> Pair.of(min, max)))
.filter(pair -> pair.getLeft().compareTo(pair.getRight()) >= 0)
.filter(pair -> pair.getLeft().compareTo(pair.getRight()) > 0)
.map(pair -> error(shape, trait, "A range trait is applied with a `min` value greater than "
+ "or equal to its `max` value."))
+ "its `max` value."))
.map(events::add);

return events;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[ERROR] ns.foo#Invalid4: Shape `ns.foo#Invalid4` is marked with the `range` trait, but its `min` property is a decimal (0.5) when its shape (`long`) does not support decimals. | RangeTrait
[ERROR] ns.foo#Invalid5: Shape `ns.foo#Invalid5` is marked with the `range` trait, but its `max` property is a decimal (10.5) when its shape (`bigInteger`) does not support decimals. | RangeTrait
[ERROR] ns.foo#Invalid5: Shape `ns.foo#Invalid5` is marked with the `range` trait, but its `min` property is a decimal (0.5) when its shape (`bigInteger`) does not support decimals. | RangeTrait
[ERROR] ns.foo#Invalid6: A range trait is applied with a `min` value greater than or equal to its `max` value. | RangeTrait
[ERROR] ns.foo#Invalid6: A range trait is applied with a `min` value greater than its `max` value. | RangeTrait
[ERROR] ns.foo#Structure$InvalidMember1: Member `ns.foo#Structure$InvalidMember1` is marked with the `range` trait, but its `max` property is a decimal (10.5) when its target (`smithy.api#Byte`) does not support decimals. | RangeTrait
[ERROR] ns.foo#Structure$InvalidMember1: Member `ns.foo#Structure$InvalidMember1` is marked with the `range` trait, but its `min` property is a decimal (0.5) when its target (`smithy.api#Byte`) does not support decimals. | RangeTrait
[ERROR] ns.foo#Structure$InvalidMember2: Member `ns.foo#Structure$InvalidMember2` is marked with the `range` trait, but its `max` property is a decimal (10.5) when its target (`smithy.api#Short`) does not support decimals. | RangeTrait
Expand All @@ -19,4 +19,4 @@
[ERROR] ns.foo#Structure$InvalidMember4: Member `ns.foo#Structure$InvalidMember4` is marked with the `range` trait, but its `min` property is a decimal (0.5) when its target (`smithy.api#Long`) does not support decimals. | RangeTrait
[ERROR] ns.foo#Structure$InvalidMember5: Member `ns.foo#Structure$InvalidMember5` is marked with the `range` trait, but its `max` property is a decimal (10.5) when its target (`smithy.api#BigInteger`) does not support decimals. | RangeTrait
[ERROR] ns.foo#Structure$InvalidMember5: Member `ns.foo#Structure$InvalidMember5` is marked with the `range` trait, but its `min` property is a decimal (0.5) when its target (`smithy.api#BigInteger`) does not support decimals. | RangeTrait
[ERROR] ns.foo#Structure$InvalidMember6: A range trait is applied with a `min` value greater than or equal to its `max` value. | RangeTrait
[ERROR] ns.foo#Structure$InvalidMember6: A range trait is applied with a `min` value greater than its `max` value. | RangeTrait
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@
"max": 10.5e4
}
},
"ValidMember13": {
"target": "smithy.api#Integer",
"range": {
"min": 5,
"max": 5
}
},
"InvalidMember1": {
"target": "smithy.api#Byte",
"range": {
Expand Down Expand Up @@ -210,6 +217,13 @@
"max": 10.5
}
},
"Valid12": {
"type": "integer",
"range": {
"min": 5,
"max": 5
}
},
"Invalid1": {
"type": "byte",
"range": {
Expand Down

0 comments on commit 32c5a03

Please sign in to comment.