validation

Set of additional JSR 349 (formerly JSR 303) constraints and validators

License

License

GroupId

GroupId

org.bongiorno
ArtifactId

ArtifactId

validation
Last Version

Last Version

1.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

validation
Set of additional JSR 349 (formerly JSR 303) constraints and validators
Project URL

Project URL

https://github.com/chb0github/validation
Source Code Management

Source Code Management

https://github.com/chb0github/validation

Download validation

How to add to project

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

Dependencies

compile (5)

Group / Artifact Type Version
javax.validation : validation-api jar 1.1.0.Final
fr.marcwrobel : jbanking jar 1.0
commons-validator : commons-validator jar 1.4.0
commons-beanutils : commons-beanutils jar 1.9.1
junit : junit jar 4.12

provided (2)

Group / Artifact Type Version
org.springframework : spring-web Optional jar 4.2.6.RELEASE
javax.mail : mail Optional jar 1.5.0-b01

test (5)

Group / Artifact Type Version
org.hibernate : hibernate-validator jar 5.1.0.Final
org.glassfish : javax.el jar 3.0.0
org.apache.commons : commons-lang3 jar 3.3.2
org.springframework : spring-test jar 4.2.6.RELEASE
org.glassfish : javax.json jar 1.0.4

Project Modules

There are no modules declared in this project.

My Stack Overflow Profile

Validation

This library provides a set of additional bean validation (JSR 349 formerly JSR 303) constraints and validators. You find the constraints in the package org.bongiorno.validation.constraints:

  • @Age: The Date must be in the past and at least that years old.
  • @Adult: The Date must be at least 18 years old.
  • @BIC: The String must be a valid BIC (Business Identifier Code) address.
  • @IBAN: The String must be a valid IBAN (International Bank Account Number) address.
  • @BitcoinAddress: Validates a bitcoin address.
  • @TLD: The String is a Top Level Domain.
  • @Domain: The String has to be a Domain.
  • @IPv4: The String has to be an IPv4 address.
  • @ContentType: The Spring MultipartFile must match a ContentType. You have to provide javax.mail for the matching.
  • @Image: The Spring MultipartFile must be an image.
  • @NotEmptyBlob: The Blob must not be empty (but can be null).
  • @Country: The String has to be a well formed ISO-3166-1 alpha-2 country code.
  • @EqualProperties: The bean has properties with equal values (e.g. two identical passwords).
  • @ISBN: The String has to be an ISBN (International Standard Book Number).

Optional Dependencies

Some constraints require further dependencies. If you want to use them you have to provide those dependencies:

  • org.bongiorno.validation.constraints.upload.* requires org.springframework.web and javax.mail.mail.

Additional Validators for JSR-349 built-ins

org.bongiorno.validation.validator.jsr349 extends some JSR-349 built-in constraints with validators for additional types:

  • SizeValidatorForMultipartFile: Validates a @Size constraint against a Spring MultipartFile.
  • PastValidatorFor…: Validates a @Past constraint against java.time (JSR 310: Date and Time API) objects.
  • FutureValidatorFor…: Validates a @Future constraint against java.time (JSR 310: Date and Time API) objects.

If you want to use these validators you have to include the mapping resource META-INF/validation/mapping.xml. This can be done by preferably create the file META-INF/validation.xml and add that mapping or you do it programmatically with Configuration.addMapping(java.io.InputStream):

<?xml version="1.0" encoding="UTF-8"?>
<validation-config
    xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.1.xsd">
    
    <constraint-mapping>META-INF/validation/mapping.xml</constraint-mapping>
</validation-config>

Maven

You find this package in Maven central:

<dependency>
    <groupId>org.bongiorno.validation</groupId>
    <artifactId>validation</artifactId>
    <version>1.0.0</version>
</dependency>

License and author

Christian Bongiorno [email protected] is the author of this project. This project is free and under the WTFPL.

Versions

Version
1.0.3