Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for @Digits JSR-303 annotation #977

Closed
john-tipper opened this issue May 2, 2019 · 1 comment
Closed

Add support for @Digits JSR-303 annotation #977

john-tipper opened this issue May 2, 2019 · 1 comment
Milestone

Comments

@john-tipper
Copy link
Contributor

Currently there is no support for the @Digits annotation (https://javaee.github.io/javaee-spec/javadocs/javax/validation/constraints/Digits.html), which is part of the JSR-303 standard (example here: https://beanvalidation.org/1.0/spec/#validationapi-message-examples).

It would be good to be able to validate BigDecimal values, which is a common requirement for financial services applications.

I'd propose having a digits field that is associated with a property, which in turn would require integerDigits and fractionalDigits to be set within that digits field.

For example (this assumes that the config option of isUseBigDecimals() returns true).

{
    "type" : "object",
    "properties" : {
        "decimal" : {
            "type" : "number",
            "digits" : {
                "integerDigits": 5,
                "fractionalDigits": 10
            }
        }
    }
}
john-tipper added a commit to john-tipper/jsonschema2pojo that referenced this issue May 2, 2019
Currently throws NoSuchElementException if either of integer and fractional digits are undefined.
@john-tipper
Copy link
Contributor Author

PR implementing the above is at #978.

john-tipper added a commit to john-tipper/jsonschema2pojo that referenced this issue May 3, 2019
Both integerDigits and fractionalDigits must be specified or else no
@digits annotation will be added.
- Amend tests to specify fractional values to end in non-zero numerals.
@joelittlejohn joelittlejohn added this to the 1.0.2 milestone May 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants