Skip to content

Add support for @Digits JSR-303 annotation #977

@john-tipper

Description

@john-tipper

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
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions