Giter VIP home page Giter VIP logo

Comments (16)

davidkarlsen avatar davidkarlsen commented on August 12, 2024

https://www.safaribooksonline.com/library/view/xml-schema/0596002521/re52.html
"
Description
xs:totalDigits defines the maximum number of digits of decimal and derived datatypes (both after and before the decimal point, not counting the decimal point itself).

This facet constrains the value space, which means that the number of digits is checked after the value is transformed to its canonical form and the leading and trailing zeros are removed.
"

Another example here: http://zvon.org/xxl/XMLSchemaTutorial/Output/ser_types_st3.html
With 10 reserved for the fractional part, that should leave 1 for the whole number part? Which seems to match the generated code?

from krasa-jaxb-tools.

mcmoulis avatar mcmoulis commented on August 12, 2024

<simpleType name="decimalType">
<restriction base="decimal">
<totalDigits value="3"/>
<fractionDigits value="2"/>
</restriction>
</simpleType>
Valid
123
123.0
123.000
12.3
1.23

Invalid
0.123
12.34
123.1

When decimals are not present then integral part is allowed to have number of digits as 'totalDigits' as per schema. But generated annotation is not going to do that if integer is (totalDigits - fractionDigits) instead totalDigits.

from krasa-jaxb-tools.

mcmoulis avatar mcmoulis commented on August 12, 2024

Digits supporting "total" (optional) along with integer and fraction will be helpful! But it wont come in the scope of this forum probably.

So even it's not exact fix it's good if we would have Digits:integer as decimal:totalDigits from schema definition?

from krasa-jaxb-tools.

davidkarlsen avatar davidkarlsen commented on August 12, 2024

If you can provide a github project demoing the issue I could attempt to fix with a pull-request.
Demo including:
minimal schema
generated bean
showing xsd validation passes
and hibnerate validator does not
or vice versa

from krasa-jaxb-tools.

akumar11 avatar akumar11 commented on August 12, 2024

@davidkarlsen : The github sample for above issue is available at https://github.com/akumar11/KrasaSample

from krasa-jaxb-tools.

davidkarlsen avatar davidkarlsen commented on August 12, 2024

@akumar11 Actually there seems to be an error with the test itself - when I fixed the filepaths all tests pass: https://github.com/akumar11/KrasaSample/pulls

from krasa-jaxb-tools.

mcmoulis avatar mcmoulis commented on August 12, 2024

By changing (correcting) test case com.test.krasa.XsdObjectValidateTest.testXsdObject we can see bug.

Modify line assertEquals(Boolean.FALSE, validateBean(travelInfoData3).isEmpty()); to assertEquals(Boolean.TRUE, validateBean(travelInfoData3).isEmpty()); then there is failure.

from krasa-jaxb-tools.

akumar11 avatar akumar11 commented on August 12, 2024

@davidkarlsen : I prepared the above sample as per Windows Environment. However, you can see @digits validation failure by changing the assertion (line#85) from Boolean.FALSE to Boolean.TRUE ( @mcmoulis explained this well in above comment ) .

from krasa-jaxb-tools.

mcmoulis avatar mcmoulis commented on August 12, 2024

Any comments/inputs?

from krasa-jaxb-tools.

krasa avatar krasa commented on August 12, 2024

Should I take a look? :-)

from krasa-jaxb-tools.

davidkarlsen avatar davidkarlsen commented on August 12, 2024

@krasa That would be great - I never came along for it.

from krasa-jaxb-tools.

davidkarlsen avatar davidkarlsen commented on August 12, 2024

@krasa Did you figure anything out?

from krasa-jaxb-tools.

krasa avatar krasa commented on August 12, 2024

Well, I agree that there is a bug :-)

I think the best would be to introduce a custom annotation+validator. That would require the plugin to be used also as a compile+runtime dependency (or make a new runtime library for just that, but that would be much more work).
And @digits should not be used when there are fractionDigits in xsd.

from krasa-jaxb-tools.

davidkarlsen avatar davidkarlsen commented on August 12, 2024

@krasa Could we not simply apply some simple arithmetics? When defining totalDigits and fractionDigits in the xsd world, leaving total-fraction=integer in the jsr303 world? http://zvon.org/xxl/XMLSchemaTutorial/Output/ser_types_st3.html
http://docs.oracle.com/javaee/6/api/javax/validation/constraints/Digits.html

from krasa-jaxb-tools.

davidkarlsen avatar davidkarlsen commented on August 12, 2024

aha - I see it now - that's actually what is happening - but leaves no space for the integral part when in fact no fraction digits are present

from krasa-jaxb-tools.

davidkarlsen avatar davidkarlsen commented on August 12, 2024

Super - this issue can be closed and put in the 1.4 milestone! Thanks a lot!

from krasa-jaxb-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.