Specify and add TCK test cases for @Digits constraint processing#733
Specify and add TCK test cases for @Digits constraint processing#733MikeEdgar wants to merge 1 commit into
@Digits constraint processing#733Conversation
Signed-off-by: Michael Edgar <michael@xlate.io>
| | `@DecimalMin(value = a)` | `number` or `integer` | `minimum = a` | ||
| | `@DecimalMin(value = a, inclusive = false)` | `number` or `integer` | `exclusiveMinimum = a` | ||
| | `@Digits(integer = <any>, fraction = f)` | `number` or `integer` | `multipleOf` equal to `1` for integer types or 10^-f for non-integer types | ||
| | `@Digits(integer = i, fraction = f)` | `string` | `pattern` matching any string value that satisfies the constraint |
There was a problem hiding this comment.
@Azquelt did we discuss having the string case in the specification or only the multipleOf for numbers?
There was a problem hiding this comment.
I'm happy to have both.
The only reason we don't have @Digits for strings already was that it was odd to have it for strings but not numbers.
There was a problem hiding this comment.
Thanks, I need to review the BV spec to make sure it's aligned there. I can imagine various gaps in how BV implementations validate cases like integer = 0 or fraction = 0. For example, do we expect @Digits(integer = 0, fraction = 2) to allow both ".25" and "0.25" or maybe the TCK just stays away from those edge cases.
| | `@DecimalMax(value = a, inclusive = false)` | `number` or `integer` | `exclusiveMaximum = a` | ||
| | `@DecimalMin(value = a)` | `number` or `integer` | `minimum = a` | ||
| | `@DecimalMin(value = a, inclusive = false)` | `number` or `integer` | `exclusiveMinimum = a` | ||
| | `@Digits(integer = <any>, fraction = f)` | `number` or `integer` | `multipleOf` equal to `1` for integer types or 10^-f for non-integer types |
There was a problem hiding this comment.
I don't think we need to generate multipleOf: 1 if the schema type is integer, since that's already implied.
There was a problem hiding this comment.
Maybe a better way to specify this would be in terms of fraction rather than in terms of the schema type. When fraction < 1, we expect multipleOf = 1, otherwise it will be 10^-f.
There was a problem hiding this comment.
Well possibly, but consider this field:
@Digits(integer = 4, fraction = 0)
int myNumber;We'd expect this schema:
{
"type": "integer",
"multipleOf": 1
}Here the multipleOf: 1 is redundant since the schema already requires an integer. I don't think we should require this.
This might mean that in the TCK we have to check for both cases: either the schema type is integer, or multipleOf: 1 is present.
Closes #717
@Digitsconstraint processing for schema propertiesTCKMatchers.NUMERIC_COMPARATORto createBigDecimalinstances from string representations of theNumberarguments, avoiding conversion errors in cast fromfloattodouble.