net.contargo:validation

Validation is a small library for validation purposes

Лицензия

Лицензия

Категории

Категории

Сеть
Группа

Группа

net.contargo
Идентификатор

Идентификатор

validation
Последняя версия

Последняя версия

1.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

net.contargo:validation
Validation is a small library for validation purposes
Ссылка на сайт

Ссылка на сайт

https://github.com/Contargo/validation
Организация-разработчик

Организация-разработчик

Contargo GmbH & Co. KG
Система контроля версий

Система контроля версий

https://github.com/contargo/validation

Скачать validation

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/net.contargo/validation/ -->
<dependency>
    <groupId>net.contargo</groupId>
    <artifactId>validation</artifactId>
    <version>1.1</version>
</dependency>
// https://jarcasting.com/artifacts/net.contargo/validation/
implementation 'net.contargo:validation:1.1'
// https://jarcasting.com/artifacts/net.contargo/validation/
implementation ("net.contargo:validation:1.1")
'net.contargo:validation:jar:1.1'
<dependency org="net.contargo" name="validation" rev="1.1">
  <artifact name="validation" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.contargo', module='validation', version='1.1')
)
libraryDependencies += "net.contargo" % "validation" % "1.1"
[net.contargo/validation "1.1"]

Зависимости

provided (1)

Идентификатор библиотеки Тип Версия
javax.validation : validation-api jar 1.1.0.Final

test (3)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
org.hamcrest : hamcrest-all jar 1.3
org.mockito : mockito-all jar 1.10.19

Модули Проекта

Данный проект не имеет модулей.

Build Status

BigDecimal Validator

The BigDecimal Validator is a small library to validate java.math.BigDecimal

Features

  • Validation of BigDecimals via Service or Annotation
    • Maximal/Minimal decimal places
    • Maximal fractional places
    • Maximal/Minimal value

#Prerequisites

  • Maven 3 or higher
  • JDK 7 or higher

Examples

Annotation driven

Test if the value of an attribute of an entity and the number of the decimal and fractional places are in the correct range.

public class Price {

    @BigDecimalValidate(
     minDecimalPlaces = 1,
     maxDecimalPlaces = 3,
     maxFractionalPlaces = 2,
     minValue = 0.00,
     maxValue = 500.00
    )
    private BigDecimal value;
    
    // Getters and Setters
}

You can also specify the message that would be shown if the validation would throw an error by adding the message property.

Service driven

public void function() {

 BigDecimalValidator validator = new BigDecimalValidator();
 
 BigDecimalValidationRules rules = new BigDecimalValidationRules.Builder()
  .minDecimalPlaces(1)
  .maxDecimalPlaces(3)
  .maxFractionalPlaces(2)
  .minValue(0.00)
  .maxValue(500.00)
  .build();
 
 BigDecimalValidationResult result = validator.validate(new BigDecimal("250.00"), rules);
 
 if(!result.isValid()) {
  System.out.println(result.getFailMessage());
 }
}

#Getting started

Simply clone this repository

$ git clone https://github.com/Contargo/big-decimal-validator.git

Build

You can run a full build including all tests with

$ mvn clean install

License

BigDecimal Validator is licensed under the Apache 2.0-license

net.contargo

Contargo GmbH & Co. KG

Версии библиотеки

Версия
1.1