Skip to content

@Digits is incorrectly generated because of differences in xsd and jsr303 #4

@Gaba1978

Description

@Gaba1978

Hi,
When I have a decimal restriction on a simpletype, then the generated @digits annotation is wrong.
test.xsd.txt
pom.xml.txt
(source files are attached).
Problematic part of xsd:
<xs:simpleType name="Amount_SimpleType">
<xs:restriction base="xs:decimal">
<xs:minInclusive value="0"/>
<xs:fractionDigits value="17"/>
<xs:totalDigits value="18"/>
</xs:restriction>
</xs:simpleType>

Generated java code:
@DecimalMin("0")
@digits(integer = 1, fraction = 17)

In xsd standard fractionDigits means MAXIMUM number of fraction digits, and totalDigits means MAXIMUM number of total digits.
In jsr303, it means MAXIMUM number of INTEGER digits and fraction digits. It describes the numbers differently.
I advise to put the value of totalDigits into the integer field. It's not the perfect solution but jsr doesn't let us define the totalDigits correctly.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions